Viewing 9 reply threads
  • Author
    Posts
    • #3205
      jmayhak
      Member

      I believe the following code should work based on https://piklist.com/user-guide/docs/field-parameters/conditions/

      However, everything is being hidden on page load. The entire group.

      I’m using Piklist 0.9.5h

      piklist('field', array(
      	'type' => 'group',
      	'scope' => '',
      	'field' => '_cn_slider',
      	'columns' => 12,
      	'add_more' => true,
      	'fields' => array(
      		array(
      			'type' => 'text',
      			'label' => 'Title',
      			'field' => 'title',
      			'columns' => 12
      		),
      		array(
      			'type' => 'textarea',
      			'label' => 'Excerpt',
      			'field' => 'excerpt',
      			'columns' => 12,
      			'attributes' => array(
      				'rows' => 6,
      				'cols' => 12
      			)
      		),
      		array(
      			'type' => 'text',
      			'field' => 'link',
      			'label' => 'Link',
      			'description' => 'eg. http://google.com',
      			'columns' => 12
      		),
      		array(
      			'type' => 'select',
      			'field' => 'is_image_or_video',
      			'label' => 'Media Type',
      			'choices' => array(
      				'image' => 'Image',
      				'video' => 'Video'
      			)
      		),
      		array(
      			'type' => 'file',
      			'field' => 'image_attachment_id',
      			'label' => 'Add Image',
      			'conditions' => array(
      				array(
      					'type' => 'toggle',
      					'field' => '_cn_slider:is_image_or_video',
      					'value' => 'image'
      				)
      			)
      		),
      		array(
      			'type' => 'text',
      			'label' => 'Link to Video',
      			'field' => 'video_src',
      			'conditions' => array(
      				array(
      					'type' => 'toggle',
      					'field' => '_cn_slider:is_image_or_video',
      					'value' => 'video'
      				)
      			)
      		)
      	)
      ));
    • #3206
      Steve
      Keymaster

      You can’t set the scope to empty. Remove the entire parameter and let Piklist set it.

    • #3207
      jmayhak
      Member

      whoops. I was experimenting with the scope property. If I remove it the same things happens.

    • #3209
      Steve
      Keymaster

      @jmayhak– I just emailed you an updated version. Let me know if that works for you.

    • #3215
      jmayhak
      Member

      got it.

      Doesn’t seem to be working with the 0.9.5m version either.

    • #3217
      Steve
      Keymaster

      @jmayhak– Your code is working beautifully for me. I see all fields, and the image/video condition works great.

      Try clearing your cache… or use another browser.

    • #3406
      jmayhak
      Member

      I noticed that the above code works in a meta-box for a post but does not work for settings. Could there be a bug when using conditions in a grouped field in the settings area?

      On line 140 of /parts/js/piklist.js is where everything is hidden (I can see the form but all the inputs are marked hidden). It’s like the toggle functionality is getting triggered on page load.

      This is the function process_fields of the class PiklistFields

    • #3414
      Steve
      Keymaster

      @jmayhak– We version of Piklist are you running? I tested with 0.9.5u and it works for me in settings.

    • #3415
      jmayhak
      Member

      Solved! I was using 0.9.4.25. 0.9.5u solved the problem.

    • #3419
      Steve
      Keymaster

      Great! Closing ticket.

Viewing 9 reply threads
  • The topic ‘Conditions used in a Grouped Field Issue’ is closed to new replies.