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 關注
- 143 瀏覽
添加回答
舉報