Viewing 4 reply threads
  • Author
    Posts
    • #7644
      randymac
      Participant

      I have a conditional tag inside a field group and instead of hiding the individual field, its hiding the entire group. I have been searching the forums and found this post from 2014, does this bug still exists from years ago? Or is it something else? Any help is appreciated.

      Here is some of my code, the first two fields are the problem ones, the second is the same but ungrouped and works properly.

      piklist('field', array(
          'type' => 'group'
          ,'field' => 'spec_hours'
          ,'label' => 'Hours'
          ,'list' => false
          //,'add_more' => true
          ,'description' => 'description here'
          ,'fields' => array(
             array(
              'type' => 'select'
              ,'field' => 'repeat_select2'
              ,'label' => __('Repeat', 'piklist-demo')
              ,'columns' => 2
              ,'choices' => array(
                 'none' => 'None'    
                 ,'weekly' => 'Weekly'
                 ,'monthly' => 'Monthly'
                 ,'yearly' => 'Yearly'
              )
            )
            ,array(
              'type' => 'select'
              ,'field' => 'repeat_days'
              ,'label' => __('Days', 'piklist-demo')
              ,'columns' => 6
              ,'list' => false
              ,'choices' => array(
             '1' => 'M','2' => 'T','3' => 'W','4' => 'T','5' => 'F','6' => 'S','7' => 'S'
              )
             ,'conditions' => array(
                  array(
                      'field' => 'spec_hours:repeat_select2'
                      ,'value' => 'weekly'
                      )
                  ) 
            )  
          )
          ,'on_post_status' => array(
            'value' => 'lock'
          )
        ));
      
            piklist('field', array(
              'type' => 'select'
              ,'field' => 'repeat_select1'
              ,'label' => __('Repeat', 'piklist-demo')
              ,'columns' => 2
              ,'choices' => array(
             'none' => 'None'    
             ,'weekly' => 'Weekly'
             ,'monthly' => 'Monthly'
             ,'yearly' => 'Yearly'
              )
            ));
            piklist('field', array(
              'type' => 'select'
              ,'field' => 'repeat_days1'
              ,'label' => __('Days', 'piklist-demo')
              ,'columns' => 6
              ,'list' => false
              ,'choices' => array(
             '1' => 'M','2' => 'T','3' => 'W','4' => 'T','5' => 'F','6' => 'S','7' => 'S'
              )
             ,'conditions' => array(
              array(
              'field' => 'repeat_select1'
              //,'value' => 'spec_hours:weekly'
              ,'value' => 'weekly'
              )
              ) 
            )); 
      
    • #7657
      Steve
      Keymaster

      @randymac– Welcome to the Piklist community!

      This code seems to be working for me. Can you send some screenshots of what you see?

      Also, you don’t need ,'field' => 'spec_hours'. If you remove it the data will save as individual meta keys which might be easier for you.

    • #7671
      randymac
      Participant

      Hi Steve, thank you for your reply. I have attached a gif of the group disappearing when selecting anything besides weekly in the first field. Its supposed to show or hide the Days field (as the second non group does).

      On your second note, I added the ,'field' => 'spec_hours', because without it, the conditional logic does nothing in that group.

      All of this is inside of a settings page for a wordpress plugin.

      Attachments:
      You must be logged in to view attached files.
    • #7685
      Steve
      Keymaster

      This seems to be working for me. Using the code you posted above:

      cloudup.com/cnrET-hYg0t

    • #7692
      randymac
      Participant

      Are you using the exact code I am? I notice your ‘description here’ is under ‘Hours’, where mine is under the first dropdown.

      I’ve done some more trial and error and discovered that I experience this bug with only with ,’on_post_status’ => array( ‘value’ => ‘lock’). I think this line was just a leftover from the sample I started with. That solves my problem, although i still have to have the field set on the group, or the conditional logic does not hide the Days.

      Thanks again for trying to help. I hope i f anyone else ends up in situation, this helps them fix it.

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