Tagged: group
- This topic has 3 replies, 2 voices, and was last updated 6 years, 3 months ago by
Steve.
-
AuthorPosts
-
-
November 1, 2015 at 5:20 am #4808
conkidMemberHi All,
Thanks for great plugin. Just learning the ins and outs now and looking to replace a lot of my past plugin toolbox.
I can’t believe I’m stuck here but if someone could tell me what I’m doing wrong. I want to group these two fields side by side, each taking up 6 columns. I do not want to group them so values return in array, so not with grouping. They keep stacking on top of each other. Everything I’ve read leads me to believe I put two fields next to each other in my code and use ‘position’ => ‘start’ on the 1st and ‘position’ => ‘end’ on the 2nd and that this should wrap them together by length of columns. Perhaps I’m missing something key?
piklist('field', array( 'type' => 'select' ,'scope' => 'post_meta' // Not used for settings sections ,'field' => 'asset_type' ,'label' => 'Select Asset Type' ,'help' => __('Select the type of Asset being logged...') ,'template' => 'post_meta_custom' ,'position' => 'start' ,'columns' => '6' ,'attributes' => array( 'class' => 'text' ) ,'choices' => array( 'laptop' => 'Laptop' ,'docking_station' => 'Docking Station' ,'monitor' => 'Monitor' ,'headset' => 'Headset' ,'office_phone' => 'Office Phone' ,'cell_phone' => 'Cell Phone' ,'software' => 'Software' ,'monitor' => 'Monitor' ,'desktop' => 'Desktop' ,'monitor' => 'Monitor' ,'ram' => 'Ram' ,'hard_drive' => 'Hard Drive' ,'battery' => 'Battery' ,'laptop_charger' => 'Laptop Charger' ) )); piklist('field', array( 'type' => 'select' ,'scope' => 'post_meta' // Not used for settings sections ,'field' => 'manufacturer' ,'label' => 'Select Manufacturer' ,'help' => __('Select the manufacturer of Asset being logged...') ,'template' => 'post_meta_custom' ,'position' => 'end' ,'columns' => '6' ,'attributes' => array( 'class' => 'text' ) ,'choices' => array( 'hp' => 'HP' ,'lenovo' => 'Lenovo' ,'monitor' => 'Monitor' ,'headset' => 'Headset' ,'office_phone' => 'Office Phone' ,'cell_phone' => 'Cell Phone' ,'software' => 'Software' ,'monitor' => 'Monitor' ,'desktop' => 'Desktop' ,'monitor' => 'Monitor' ,'ram' => 'Ram' ,'hard_drive' => 'Hard Drive' ,'battery' => 'Battery' ,'laptop_charger' => 'Laptop Charger' ) )); -
November 1, 2015 at 7:39 am #4809
SteveKeymaster@conkid– Welcome to the Piklist community!
When you use a
groupfield, the data can be save in an array, OR as separate values. If you use a field name at the group level, like you did withasset_type, the data will be in an array. If you remove that, and just use field names for each field then it won’t.Try this updated code. It places two select fields side-by-side, 6 columns each (Piklist uses a 12 column grid).
piklist('field', array( 'type' => 'group' ,'label' => 'Select Asset Type' ,'help' => __('Select the type of Asset being logged...') ,'fields' => array( array( 'type' => 'select' ,'field' => 'asset_type' ,'label' => 'Select Asset' ,'columns' => 6 ,'choices' => array( 'laptop' => 'Laptop' ,'docking_station' => 'Docking Station' ,'monitor' => 'Monitor' ,'headset' => 'Headset' ,'office_phone' => 'Office Phone' ,'cell_phone' => 'Cell Phone' ,'software' => 'Software' ,'monitor' => 'Monitor' ,'desktop' => 'Desktop' ,'monitor' => 'Monitor' ,'ram' => 'Ram' ,'hard_drive' => 'Hard Drive' ,'battery' => 'Battery' ,'laptop_charger' => 'Laptop Charger' ) ) ,array( 'type' => 'select' ,'field' => 'manufacturer' ,'label' => 'Select Manufacturer' ,'columns' => 6 ,'help' => __('Select the manufacturer of Asset being logged...') ,'choices' => array( 'hp' => 'HP' ,'lenovo' => 'Lenovo' ,'monitor' => 'Monitor' ,'headset' => 'Headset' ,'office_phone' => 'Office Phone' ,'cell_phone' => 'Cell Phone' ,'software' => 'Software' ,'monitor' => 'Monitor' ,'desktop' => 'Desktop' ,'monitor' => 'Monitor' ,'ram' => 'Ram' ,'hard_drive' => 'Hard Drive' ,'battery' => 'Battery' ,'laptop_charger' => 'Laptop Charger' ) ) ) ));Let me know if this is what you’re looking for.
Attachments:
You must be logged in to view attached files. -
November 11, 2015 at 12:00 am #4918
conkidMemberSteve – this is just what I needed. Sorry for my late reply. I’m back in it now and digging it, next question coming soon 🙂
-
November 11, 2015 at 10:09 am #4922
SteveKeymasterGreat. Closing ticket. Let us know if you need more help.
-
-
AuthorPosts
- The topic ‘Grouping Fields – Noob Question’ is closed to new replies.