Tagged: optgroup
- This topic has 5 replies, 2 voices, and was last updated 6 years, 1 month ago by
Steve.
-
AuthorPosts
-
-
December 12, 2015 at 7:56 am #5308
kabadabraMemberHi there,
Is there a way to set certain options when using select fields?
For example
Electronics (Parent)
– Computers (Child)
– Mobile (Child)Would like to set all parent options in a select list to be disabled.
-
December 14, 2015 at 12:47 pm #5329
SteveKeymaster@kabadabra– Piklist uses standard HTML form attributes.
Add this to any Piklist field array that you want disabled:
'attributes' => array( 'disabled' => 'disabled' )
This will make the form disabled
-
December 14, 2015 at 3:36 pm #5342
kabadabraMemberHi Steve, I think you misunderstood what I’m trying to do.
I have a select list like the following: https://dl.dropboxusercontent.com/s/cubjkioi629s2h3/2015-12-14%20at%2021.33.jpg
I want to make certain <options> disabled but not sure how you set an attribute per choice? The code that you’ve given above would make a whole field or select disabled.
I managed to build a workaround as per in my screenshot for getting custom taxonomies saved from the front end. But it’s a long way around to something potentially simple.
Appreciate your feedback and thoughts as always, thank you.
-
December 14, 2015 at 3:56 pm #5344
SteveKeymasterI think you mean OPTION GROUPS
You can see an example in Piklist Demos > Common > Lists > Select with Option Groups
piklist('field', array( 'type' => 'select' ,'field' => 'select_optgroup' ,'label' => __('Select with Option Groups', 'piklist-demo') ,'value' => 'third' ,'choices' => array( 'Group 1' => array( 'first' => __('First Choice', 'piklist-demo') ,'second' => __('Second Choice', 'piklist-demo') ,'third' => __('Third Choice', 'piklist-demo') ) ,'Group 2' => array( 'first' => __('First Choice', 'piklist-demo') ,'second' => __('Second Choice', 'piklist-demo') ,'third' => __('Third Choice', 'piklist-demo') ) ) ));Let us know if this works for you.
-
December 14, 2015 at 4:06 pm #5345
kabadabraMemberPerfect, this makes sense now. Thanks Steve! LEGEND!
-
December 14, 2015 at 5:14 pm #5348
SteveKeymasterNice! Closing ticket.
-
-
AuthorPosts
- The topic ‘Disable options on select’ is closed to new replies.