- This topic has 4 replies, 3 voices, and was last updated 7 years, 10 months ago by
Sander Schat.
-
AuthorPosts
-
-
November 9, 2012 at 11:01 am #375
Sander SchatMemberhi!
is there way to add an extra choice to the ‘select’ dropdown when using it with a WP function, like so:
piklist('field', array(
'type' => 'select'
,'field' => 'search'
,'label' => 'seach page'
,'attributes' => array(
'class' => 'text'
)
,'choices' => piklist(
get_pages(
array(
'sort_order' => 'ASC',
'sort_column' => 'post_title',
'post_type' => 'page',
'post_status' => 'publish'
)
,'objects'
)
,array(
'id'
,'post_title'
)
)
));
this gets the pages, but i would like to add the ‘first’ option myself, to include it with a different text like ‘please select page…’
Also, what does ‘objects’ mean in this case?
-
November 10, 2012 at 4:21 am #376
Daniel MénardMemberHi,
Here is what I did in my own code:
[...]
,'choices' =>
array('first-option-value' => 'first option label')
+
piklist( get_pages( [...] ) )
[...]
Hope it helps !
Cheers,
Daniel
-
November 10, 2012 at 6:32 am #378
Sander SchatMemberyes, works!
thanks -
November 12, 2012 at 1:51 am #382
KevinKeymasterHi Guys-
I do the same thing, however one thing to keep in mind is that the above method won’t work on all server setups. I usually try and stick with array_splice and array_push for these types of things just to be on the safe side 🙂
Thanks,
Kevin
-
April 2, 2014 at 3:49 am #1634
Sander SchatMemberis it an ‘idea’ to have this as an extra option by default in Piklist?
I do this with every field just to make it clear to the user,
there is NO value selected when showing for the first time.
-
-
AuthorPosts
- You must be logged in to reply to this topic.