Tagged: ,

Viewing 3 reply threads
  • Author
    Posts
    • #5700
      jivedig
      Member

      I am trying to implement conditional fields on a front end form. I have it working, but only when both field’s scope is the same. We should be able to have a different scope while still allowing conditional fields.

      Here are the 2 fields i’m using. Change the scope to the same and it will work.

      piklist('field', array(
        'type'    => 'radio',
        'scope'   => 'post',
        'field'   => 'post_status',
        'label'   => 'When would you like to post this?',
        'value'   => 'publish',
        'choices' => array(
          'publish' => 'Immediately',
          'future'  => 'Schedule a future date',
        ),
      ));
      
      piklist('field', array(
        'type'       => 'datepicker',
        'scope'      => 'post_meta',
        'field'      => 'post_date',
        'label'      => 'Scheduled Post Date',
        'columns'    => 2,
        'options' => array(
          'dateFormat' => 'm-d-y',
          'firstDay'   => '1',
        ),
        'validate' => array(
          array(
            'type' => 'today_or_future',
          ),
        ),
        'conditions' => array(
          array(
            'field' => 'post_status',
            'value' => 'future',
          ),
        ),
      ));
    • #5701
      jivedig
      Member

      Interesting update…

      I can add the scope to the conditions array and now it works.

        'conditions' => array(
          array(
            'scope' => 'post',
            'field' => 'post_status',
            'value' => 'future',
          ),
        ),
    • #5703
      Steve
      Keymaster

      @jivedig– Glad you figured it out. scope is very important for front-end forms since Piklist can’t auto-detect it.

      Closing this ticket.

    • #5704
      jivedig
      Member

      Thanks, I realize how important it is for the fields themselves, but didn’t realize it mattered for the conditions themselves. Thanks 😉

Viewing 3 reply threads
  • The topic ‘Conditional fields not working when scope is different’ is closed to new replies.