Tagged: add_more, conditions, groups
- This topic has 11 replies, 7 voices, and was last updated 6 years, 11 months ago by
Steve.
-
AuthorPosts
-
-
August 7, 2014 at 7:34 pm #2176
MarcusMemberOk, found a new bug with conditionals.
I have an add-more that has a conditional inside it, that if a checkbox is not checked, then the text field should show.
Problem is, as I create the add-mores, as that box is checked, all text fields with the condition show or hide, instead of just the field for that add-more row.Here’s the code:
piklist('field', array ( 'type' => 'group' ,'label' => 'Refund Info' ,'field' => 'mae_merch_useprevpay' ,'add_more' => true ,'fields' => array( array ( 'type' => 'select' ,'label' => 'Use Previous Payment' ,'field' => 'mae_merch_pay_upp' ,'columns' => 12 ,'attributes' => array( 'class' => array( 'show-tick' ) ,'data-live-search'=>true ,'data-style'=>'btn-danger' ,'data-size'=>5 ,'data-width'=>'100%' // auto, or 100% or px or comment out ,'data-header'=>'Please select a Previous Payment...' ,'onfocus' => 'javascript: jQuery(this).selectpicker();' ) ,'conditions' => array( array( 'field' => 'mae_merch_pay_status' ,'value' => 'camps-refund' ) ) ) ,array ( 'type' => 'text' ,'label' => 'Payment $' ,'field' => 'mae_merch_pay_rppp' ,'attributes' => array( 'size' => 6 ) ,'value' => '' ,'columns' => 2 ) ,array ( 'type' => 'text' ,'label' => 'TxRefNum' ,'field' => 'mae_merch_pay_rpptx' ,'attributes' => array( 'size' => 18 ) ,'value' => '' ,'columns' => 5 ) ,array ( 'type' => 'checkbox' ,'field' => 'mae_merch_pay_rppra' ,'label' => 'Refund Total?' ,'value' => '' ,'choices' => array( 'y'=>'Yes' ) ,'columns' => 3 ) ,array ( 'type' => 'text' ,'label' => 'Amount $' ,'field' => 'mae_merch_pay_rpppra' ,'attributes' => array( 'size' => 6 ) ,'value' => '' ,'conditions' => array( array( 'field' => 'mae_merch_useprevpay:mae_merch_pay_rppra' ,'value' => array('') ) ) ,'columns' => 2 ) ) ));And here’s the result:

Marcus
-
August 8, 2014 at 3:01 pm #2180
JasonKeymasterI just ran into a similar issue, but on top of it affecting every instance, mine also has the added bonus that if I select “Custom”, it makes the entire group disappear.
piklist('field', array( 'description' => 'Limit: 3 Sections', 'type' => 'group', 'field' => 'footer-widgets', 'label' => 'Footer Sections', 'add_more' => true, 'validate' => array( array( 'type' => 'limit', 'options' => array( 'min' => 1, 'max' => 3 ) ) ), 'fields' => array( array( 'type' => 'text', 'field' => 'title', 'label' => 'Title', 'columns' => 6 ), array( 'type' => 'textarea', 'field' => 'content', 'label' => 'Content', 'columns' => 12 ), array( 'type' => 'text', 'field' => 'link-text', 'label' => 'Link Text', 'columns' => 4 ), array( 'type' => 'radio', 'field' => 'link-type', 'label' => 'Link Type', 'value' => 'post', 'list' => false, 'choices' => array( 'post' => 'post/page', 'custom' => 'Custom' ) ), array( 'type' => 'text', 'field' => 'link-url', 'label' => 'Custom URL', 'conditions' => array( array( 'field' => 'footer-widgets:link-type', 'value' => array('custom') ) ) ), array( 'type' => 'select-post', 'field' => 'link-post-id', 'label' => 'Post to Link', 'options' => array( 'characters' => 30 ), 'conditions' => array( array( 'field' => 'footer-widgets:link-type', 'value' => array('post') ) ) ) ) ));And because animated gifs are fun:

-
August 8, 2014 at 3:13 pm #2182
KevinKeymasterYou guys rock, always pushing the new feature as soon as it comes out 🙂 We have added this to our very small but current issue list and should have it resolved in the next release which is planned for sometime next week.
Thanks again for reporting this and being so thorough, the gifs rock!
Kevin
-
August 8, 2014 at 5:09 pm #2189
MarcusMemberThanks Kevin.
Nice one Jason. Broke it real good. 🙂
Marcus
-
August 8, 2014 at 7:36 pm #2191
cyclissmoMemberMy contribution, possibly related:
/** * Business hours */ piklist('field', array( 'type' => 'group', 'label' => 'Business hours', 'add_more' => true, 'columns' => 12, 'fields' => array( array( 'type' => 'select', 'field' => 'jnl-from', 'choices' => array( 'Monday' => 'Monday', 'Tuesday' => 'Tuesday', 'Wednesday' => 'Wednesday', 'Thursday' => 'Thursday', 'Friday' => 'Friday', 'Saturday' => 'Saturday', 'Sunday' => 'Sunday' ), 'attributes' => array( 'style' => 'float:left;' ) ), array( 'type' => 'html', 'field' => '', 'value' => 'Through', 'attributes' => array('style' => 'float:left;margin:0 12px;'), ), array( 'type' => 'select', 'field' => 'jnl-to', 'choices' => array( 'Monday' => 'Monday', 'Tuesday' => 'Tuesday', 'Wednesday' => 'Wednesday', 'Thursday' => 'Thursday', 'Friday' => 'Friday', 'Saturday' => 'Saturday', 'Sunday' => 'Sunday' ), ), // Hours sub-group array( 'type' => 'group', 'field' => 'jnl-hours', 'add_more' => true, 'columns' => 12, 'fields' => array( array( 'type' => 'select', 'field' => 'jnl-from-time-hour', 'choices' => array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'), 'attributes' => array( 'style' => 'float:left;' ), ), array( 'type' => 'select', 'field' => 'jnl-from-time-minutes', 'choices' => array(':00 AM', ':30 AM', ':00 PM', ':30 PM'), 'attributes' => array( 'style' => 'float:left;' ), ), array( 'type' => 'html', 'field' => '', 'value' => 'To', 'attributes' => array( 'style' => 'float:left;margin:0 12px;' ) ), array( 'type' => 'select', 'field' => 'jnl-to-time-hour', 'choices' => array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'), 'attributes' => array( 'style' => 'float:left;' ), ), array( 'type' => 'select', 'field' => 'jnl-to-time-minutes', 'choices' => array(':00 AM', ':30 AM', ':00 PM', ':30 PM'), 'attributes' => array( 'style' => 'float:left;' ), ), ) ), ) )); -
August 9, 2014 at 3:55 am #2192
kattagamiMemberThis is my contribution:
This code works perfectly but if I put it in a group/add-more field it doesn’t work anymore.
NO group/add-more
piklist( 'field', array( 'type' => 'radio', 'scope' => 'post_meta', 'field' => 'katt_schedule_choice', 'value' => 'show', // Sets default to show 'label' => 'Choose a Break or a Presentation', 'help' => 'To build your schedule you can insert a presentation or a break.', 'attributes' => array( 'class' => 'text', ), 'choices' => array( 'presentation' => 'Presentation', 'break' => 'Break', ), ) ); piklist( 'field', array( 'type' => 'text', 'field' => 'katt_schedule_break', 'label' => 'Break', 'help' => 'If you need to insert a break (Welcome, Coffee, Lunch ...) in your schedule, use this field.', 'conditions' => array( array( 'field' => 'katt_schedule_choice', 'value' => array( 'presentation' ), 'compare' => '!=' ), ), ) ); piklist( 'field', array( 'type' => 'select', 'field' => 'katt_schedule_presentation', 'label' => 'Presentations', 'help' => 'Choose a presentation to build your schedule.', 'conditions' => array( array( 'field' => 'katt_schedule_choice', 'value' => array( 'break' ), 'compare' => '!=' ), ), ) );IN a group/add-more field:
piklist( 'field', array ( 'type' => 'group', 'field' => 'katt_schedule_group', 'add_more' => true, 'label' => __( 'Presentation or Break' , 'katt' ), 'help' => __( 'To build your schedule you can insert a presentation or a break.' , 'katt' ), 'fields' => array( array( 'type' => 'radio', 'scope' => 'post_meta', 'field' => 'katt_schedule_choice', 'value' => 'show', // Sets default to show 'label' => __( 'Choose:' , 'katt' ), 'attributes' => array( 'class' => 'text', ), 'choices' => array( 'presentation' => __( 'Presentation' , 'katt' ), 'break' => __( 'Break' , 'katt' ), ), ), array( 'type' => 'text', 'field' => 'katt_schedule_break', 'label' => __( 'Break' , 'katt' ), 'help' => __( 'If you need to insert a break (Welcome, Breakfast, Coffee break, Lunch ...) in your schedule, use this field.' , 'katt' ), 'conditions' => array( array( 'field' => 'katt_schedule_choice', 'value' => 'presentation', 'compare' => '!=' ), ), ), array( 'type' => 'select', 'field' => 'katt_schedule_presentation', 'label' => __( 'Presentations' , 'katt' ), 'help' => __( 'Choose a presentation to build your schedule.' , 'katt' ), 'conditions' => array( array( 'field' => 'katt_schedule_choice', 'value' => 'break', 'compare' => '!=' ), ), ) ) ) ); -
August 9, 2014 at 12:16 pm #2193
MarcusMemberHi Kattagami.
Did you make sure to reference the outside group name inside your conditional?
I posted an example of a problem I had earlier, that turned out I had just forgotten. 🙂So for your line:
'field' => 'katt_schedule_choice',
It should read:
'field' => 'katt_schedule_group:katt_schedule_choice',Does that make it work?
Marcus
-
August 9, 2014 at 4:23 pm #2194
kattagamiMemberThanks Marcus,
Now I can see my two conditional fields and I’ve got the same bug as you.
I didn’t see in the Piklist “User Guide” that we need to reference the outside group name inside the conditional.
Where did you see this instruction? -
February 16, 2015 at 1:05 pm #3318
justinMemberI am having a similar issue, If the group does not have a field name, how would I reference it?
Here is my code:
<?php /* Title: User General Description: General Info for all Users */ piklist('field', array( 'type' => 'select' ,'field' => 'user_country' ,'value' => 'US' // Sets default to US ,'label' => 'Country' ,'choices' => array( 'AF'=>'Afghanistan', 'AL'=>'Albania', 'EE'=>'Estonia', 'ET'=>'Ethiopia', 'FK'=>'Falkland Islands (Malvinas)', 'FO'=>'Faroe Islands', 'FJ'=>'Fiji', 'US'=>'United States', 'UM'=>'United States Minor Outlying Islands', 'UY'=>'Uruguay', 'UZ'=>'Uzbekistan', 'VU'=>'Vanuatu', 'VA'=>'Vatican City (Holy See)', 'VE'=>'Venezuela', 'VN'=>'Vietnam', 'VG'=>'Virgin Islands (British)', 'VI'=>'Virgin Islands (US)', 'WF'=>'Wallis And Futuna Islands', 'EH'=>'Western Sahara', 'WS'=>'Western Samoa', 'YE'=>'Yemen', 'YU'=>'Yugoslavia', 'ZM'=>'Zambia', 'ZW'=>'Zimbabwe' ) )); piklist('field', array( 'type' => 'group' ,'label' => 'Address' ,'fields' => array( array( 'type' => 'text' ,'field' => 'user_address_1' ,'label' => 'Street Address' ,'columns' => 12 ) ,array( 'type' => 'text' ,'field' => 'user_address_2' ,'label' => 'PO Box, Suite, etc.' ,'columns' => 12 ) ,array( 'type' => 'text' ,'field' => 'user_city' ,'label' => 'City' ,'columns' => 5 ) ,array( 'type' => 'select' ,'field' => 'user_state' ,'label' => 'State' ,'columns' => 4 ,'conditions' => array( array( 'field' => 'user_country' ,'value' => 'US' ) ) ,'choices' => array( 'AL' => 'Alabama' ,'AK' => 'Alaska' ,'AZ' => 'Arizona' ,'AR' => 'Arkansas' ,'CA' => 'California' ,'CO' => 'Colorado' ,'CT' => 'Connecticut' ,'DE' => 'Delaware' ,'DC' => 'District Of Columbia' ,'FL' => 'Florida' ,'GA' => 'Georgia' ,'HI' => 'Hawaii' ,'ID' => 'Idaho' ,'IL' => 'Illinois' ,'IN' => 'Indiana' ,'IA' => 'Iowa' ,'KS' => 'Kansas' ,'KY' => 'Kentucky' ,'LA' => 'Louisiana' ,'ME' => 'Maine' ,'MD' => 'Maryland' ,'MA' => 'Massachusetts' ,'MI' => 'Michigan' ,'MN' => 'Minnesota' ,'MS' => 'Mississippi' ,'MO' => 'Missouri' ,'MT' => 'Montana' ,'NE' => 'Nebraska' ,'NV' => 'Nevada' ,'NH' => 'New Hampshire' ,'NJ' => 'New Jersey' ,'NM' => 'New Mexico' ,'NY' => 'New York' ,'NC' => 'North Carolina' ,'ND' => 'North Dakota' ,'OH' => 'Ohio' ,'OK' => 'Oklahoma' ,'OR' => 'Oregon' ,'PA' => 'Pennsylvania' ,'RI' => 'Rhode Island' ,'SC' => 'South Carolina' ,'SD' => 'South Dakota' ,'TN' => 'Tennessee' ,'TX' => 'Texas' ,'UT' => 'Utah' ,'VT' => 'Vermont' ,'VA' => 'Virginia' ,'WA' => 'Washington' ,'WV' => 'West Virginia' ,'WI' => 'Wisconsin' ,'WY' => 'Wyoming' ) ) ,array( 'type' => 'text' ,'field' => 'user_postal_code' ,'label' => 'Postal Code' ,'columns' => 3 ,'conditions' => array( array( 'field' => 'user_country' ,'value' => 'US' ) ) ) ) )); piklist('field', array( 'type' => 'tel' ,'field' => 'user_number' ,'label' => 'Phone Number' )); ?>When I select a country that is not the US, the entire group disappears instead of just the city and zip code. I think the solution that Marcus proposed would work if it had a field name, but I do not want my data serialized. I have almost the exact same code on a normal meta box and the condition works fine, but when using it on my user profile it does not work as desired.
thanks
-
February 17, 2015 at 11:55 am #3321
-
February 19, 2015 at 12:36 am #3323
-
-
AuthorPosts
- You must be logged in to reply to this topic.