Viewing 10 reply threads
  • Author
    Posts
    • #2176
      Marcus
      Member

      Ok, 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:
      Condition bug

      Marcus

    • #2180
      Jason
      Keymaster

      I 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:

    • #2182
      Kevin
      Keymaster

      You 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

    • #2189
      Marcus
      Member

      Thanks Kevin.

      Nice one Jason. Broke it real good. 🙂

      Marcus

    • #2191
      cyclissmo
      Member

      My 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;'
      					),
      				),
      			) 
      		),
      		
      		
      	)
      ));

      Screen capture

    • #2192
      kattagami
      Member

      This 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' => '!='
      	    							),
      	    						),
      			)
      		)
      	)
      );
    • #2193
      Marcus
      Member

      Hi 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

    • #2194
      kattagami
      Member

      Thanks 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?

      • #2195
        Marcus
        Member

        I don’t think its in the user guide. It will eventually I’m sure.
        It came from a previous bug, and got the answer, then forgot it.

        Marcus

    • #3318
      justin
      Member

      I 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

    • #3321
      Steve
      Keymaster

      @justin– You definitely found a bug. This code works great for post_meta, but not Users. We will put it on the list of fixes we need to address.

    • #3323
      Steve
      Keymaster

      @justin– We believe we have a fix for this issue. I will be sending you a beta version of Piklist in the next few days.

Viewing 10 reply threads
  • You must be logged in to reply to this topic.