Viewing 1 reply thread
  • Author
    Posts
    • #7778
      gthomason
      Participant

      I’m creating a grouped repeater where the user selects a layout option and fields appear based off of that selection. This does not appear to be working when the conditional sets are grouped. I’ve also noticed your demo does not work grouped.

      A smaller issue is if I have a validation limit on add more items; it looks at all items in the group; not just inside the repeater – but I don’t really care about that since the conditional is a bigger deal.

      My piklist group:

      piklist('field', array(
      	'type' => 'group',
      	'field' => 'featured_bottom_group',
      	'label' => __('Overview Bottom boxes (grouped)', 'gst_piklist'),
      	'description' => __('A grouped field with a key set. Data is not searchable, since it is saved in an array.', 'piklist-demo'),
      	'list' => true,
      	'add_more' => true,
      	'validate' => array(
      		array(
      			'type' => 'limit',
      			'options' => array(
      				'min' => 0,
      				'max' => 4,
      			)
      		)
      	),
      	'attributes' => array(
      		'class' => 'piklist_group' // WordPress css class 
      	),
      	'fields' => array(
      		array(
      			'type' => 'select',
      			'field' => 'bottom_condtional',
      			'label' => 'What type of content is in this box?',
      			'value' => 'textarea',
      			'choices' => array(
      				'textarea' => 'Textarea',
      				'list' => 'Text List + Icon',
      			),
      			'attributes' => array(
      				'class' => 'piklist_select' // WordPress css class 
      			),
      			
      		),
      		array(
      			'type' => 'text',
      			'field' => 'bottom_title',
      			'label' => 'Box Title',
      			'list' => true,
      			'attributes' => array(
      				'class' => 'piklist_text' // WordPress css class 
      			),
      		),
      		array(
      			'type' => 'textarea',
      			'field' => 'bottom_textarea',
      			'label' => 'Box Content',
      			'list' => true,
      			'attributes' => array(
      				'rows' => 5,
      				'cols' => 100,
      				'class' => 'piklist_textarea' // WordPress css class 
      			),
      			// This doesn't work
      			'conditions' => array(
      				array(
      					'field' => 'bottom_condtional',
      					'value' => 'textarea'
      				)
      			),
      		),
      		array(
      			'type' => 'group',
      			'field' => 'bottom_link_group',
      			'label' => __('Enter Anchor and Select Icon', 'gst_piklist'),
      			'list' => true,
      			'add_more' => true,
      			// This doesn't work
      			'conditions' => array(
      				array(
      					'field' => 'bottom_condtional',
      					'value' => 'list'
      				)
      			),
      			'attributes' => array(
      				'class' => 'piklist_group' // WordPress css class 
      			),
      			'fields' => array(
      				array(
      					'type' => 'select',
      					'field' => 'bottom_link_icon',
      					'label' => 'Anchor Icon',
      					'list' => true,
      					'choices' => array(
      						'none' => 'None',
      						'arrow' => 'Arrow',
      						'circle' => 'Circle',
      					),
      					'attributes' => array(
      						'class' => 'piklist_select' // WordPress css class 
      					),
      
      				), // end 	bottom_link_icon
      				array(
      					'type' => 'text',
      					'field' => 'bottom_link_text',
      					'label' => 'Anchor Link',
      					'list' => true,
      					'attributes' => array(
      						'class' => 'piklist_text' // WordPress css class 
      					),
      				), // end 	bottom_link_text	
      			)
      		), // end bottom_link_group 
      	)
      ));

      Piklist Demo’s code that works:

      piklist('field', array(
      	 'type' => 'select',
      	 'field' => 'subscribe_to_newsletter',
      	 'label' => 'Would you like to subscribe to our newsletter?',
      	 'attributes' => array(
      	 	'class' => 'text',
      	 ),
      	 'choices' => array(
      	   'yes' => 'Yes'
      	   ,'no' => 'No'
      	 ),
      	 'value' => 'no'
      ));
      	
      piklist('field', array(
      	'type' => 'text',
      	'field' => 'my_text',
      	'label' => 'Text',
      	'conditions' => array(
      		array(
      			'field' => 'subscribe_to_newsletter'
      			,'value' => 'yes'
      		)
      	),
      	'attributes' => array(
      		'class' => 'regular-text' // WordPress css class 
      	)
      ));

      Piklist Demo’s code that doesn’t work if grouped:

      piklist('field', array(
      	'type' => 'group',
      	'field' => 'featured_bottom_group',
      	'label' => __('Overview Bottom boxes (grouped)', 'fxcm_piklist'),
      	'description' => __('A grouped field with a key set. Data is not searchable, since it is saved in an array.', 'piklist-demo'),
      	'list' => true,
      	'add_more' => true,
      	'validate' => array(
      		array(
      			'type' => 'limit',
      			'options' => array(
      				'min' => 0,
      				'max' => 4,
      			)
      		)
      	),
      	'attributes' => array(
      		'class' => 'piklist_group' // WordPress css class 
      	),
      	'fields' => array(
      		array(
      			 'type' => 'select',
      			 'field' => 'subscribe_to_newsletter',
      			 'label' => 'Would you like to subscribe to our newsletter?',
      			 'attributes' => array(
      			 	'class' => 'text',
      			 ),
      			 'choices' => array(
      			   'yes' => 'Yes'
      			   ,'no' => 'No'
      			 ),
      			 'value' => 'no'
      		),	
      		array(
      			'type' => 'text',
      			'field' => 'my_text',
      			'label' => 'Text',
      			'conditions' => array(
      				array(
      					'field' => 'subscribe_to_newsletter'
      					,'value' => 'yes'
      				)
      			),
      			'attributes' => array(
      				'class' => 'regular-text' // WordPress css class 
      			)
      		)	
      	)
      ));
    • #7780
      Steve
      Keymaster

      @gthomason– Welcome to the Piklist Community!

      Unfortunately, there are issues with groups within groups with add-mores and conditions right now. You may want to try breaking this field up into tabs instead.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.