1 回答
TA贡献1777条经验 获得超10个赞
我想我找到了解决方案:
在第一个之前,GF_Fields::create我必须从第二个函数中复制以下代码:
$args = array(
'orderby' => 'title',
'order' => 'ASC',
'numberposts' => -1,
'post_type' => 'movie',
'post_status' => array('publish'),
);
$posts = get_posts( $args );
$choices = array();
foreach ( $posts as $post ) {
$choices[] = array(
'text' => $post->post_title,
'value' => $post->post_title
);
}
然后我必须GF_Fields::create像这样编辑第一个:
$movie_sku = GF_Fields::create( array(
'type' => 'select',
'id' => 1002, // The Field ID must be unique on the form
'formId' => $form['id'],
'required' => true,
'label' => 'Movie',
'choices' => $choices,
'pageNumber' => 1, // Ensure this is correct
) );
新部分是'choices' => $choices,从上面的代码中获取数据的部分。当然,我必须将输入类型更改为 select: 'type' => 'select',。
- 1 回答
- 0 关注
- 110 浏览
添加回答
举报