Tagged: empty option, field, select
- This topic has 2 replies, 2 voices, and was last updated 5 years, 10 months ago by
Steve.
Viewing 2 reply threads
-
AuthorPosts
-
-
April 3, 2016 at 6:41 am #6234
martinwMemberI’m trying out Piklist and so far it’s really great!
Currently i try to add relationships to custom-post-types as well as users.
So i need to add a field to the user where administrators can select none or one entry from a custom-post-type.
This is what i have/found and added to the parts/users-folder.
So far it works, but i can not select an emtpy option, i always have to select an existing post.
Is it possible to add an emtpy option to the top of the list?
how would i do that?piklist('field', array( 'type' => 'select' , 'field' => 'current_selection' , 'label' => __('Current Selection') , 'description' => __('Currently selected Post') , 'attributes' => array( 'class' => 'text' ) , 'choices' => piklist( get_posts(array( 'post_type' => 'my-custom-post-type', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' )), array('ID', 'post_title') ), )); -
April 3, 2016 at 8:08 am #6235
martinwMemberDid it!
$array = array_merge( array(0 => "--- None ---"), piklist( get_posts(array( 'post_type' => 'my-custom-post-type', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' )), array('ID', 'post_title') ) ); piklist('field', array( 'type' => 'select' , 'field' => 'current_selection' , 'label' => __('Current Selection') , 'description' => __('Currently selected Post') , 'attributes' => array( 'class' => 'text' ) , 'choices' => $array )); -
April 3, 2016 at 9:48 pm #6238
SteveKeymasterNice! Closing ticket.
-
-
AuthorPosts
Viewing 2 reply threads
- The topic ‘work with relationships’ is closed to new replies.