Viewing 5 reply threads
  • Author
    Posts
    • #5629
      notaname
      Member

      If at least one field should be hidden by condition in group field whole metabox not displayed in Setting page, for Page its work well:

      piklist/parts/settings/hf-settings.php:

      
      <?php
      /*
      Title: Header and Footer settings
      Setting: hf_settings
      */
      piklist('field', array(
          'type' => 'group'
          ,'field' => 'fruit_settings'
          ,'label' => __('Settings')
          ,'add_more' => true
          ,'fields' => array(
            array(
              'type' => 'select'
              ,'field' => 'country'
              ,'label' => 'Country'
              ,'columns' => 12
              ,'choices' => array(
                  'US' => 'United States'
                  ,'EU' => 'European Union'
                )
              )
              ,array(
                'type' => 'select'
                ,'field' => 'fruits'
                ,'label' => 'Fruits'
                ,'columns' => 12
                ,'choices' => array(
                  'apples' => 'Apples'
                  ,'oranges' => 'Oranges'
                )
              )
              ,array(
                'type' => 'select'
                ,'field' => 'apples'
                ,'label' => 'Apples'
                ,'columns' => 12
                ,'choices' => array(
                  'aceymac' => 'Aceymac Apple'
                  ,'akero' => 'Akero Apple'
                )
                ,'conditions' => array(
                  array(
                    'field' => 'fruit_settings:fruits'
                    ,'value' => 'apples'
                  )
                )
              )
              ,array(
                'type' => 'select'
                ,'field' => 'oranges'
                ,'label' => 'Oranges'
                ,'columns' => 12
                ,'choices' => array(
                  'blood' => 'Blood Orange'
                  ,'navel' => 'Navel Orange'
                )
                ,'conditions' => array(
                  array(
                    'field' => 'fruit_settings:fruits'
                    ,'value' => 'oranges'
                  )
                )
              )
          )
        ));

      Code in function.php

      add_filter('piklist_admin_pages', 'piklist_theme_setting_pages');
        function piklist_theme_setting_pages($pages)
        {
           $pages[] = array(
            'page_title' => __('Header Footer settings')
            ,'menu_title' => __('Header and Footer', 'piklist')
            ,'sub_menu' => 'themes.php' //Under Appearance menu
            ,'capability' => 'manage_options'
            ,'menu_slug' => 'custom_settings'
            ,'setting' => 'hf_settings'
            ,'menu_icon' => plugins_url('piklist/parts/img/piklist-icon.png')
            ,'page_icon' => plugins_url('piklist/parts/img/piklist-page-icon-32.png')
            ,'single_line' => true
            ,'default_tab' => 'Basic'
            ,'save_text' => 'Save'
          );
      
          return $pages;
        } 
    • #5631
      notaname
      Member

      It is bug or need additional parameter in some field?

    • #5639
      notaname
      Member

      Can anybody confirm this? Just try code above. In custom Setting page metabox should blink after booting and disapeer, if comment this code:

                ,'conditions' => array(
                  array(
                    'field' => 'fruit_settings:fruits'
                    ,'value' => 'apples'
                  )
                )

      fields showing normal, if select oranges, meta disapeering.
      For Page, Post work normal.

    • #5655
      notaname
      Member

      Steve, please, check this case, really need your help. Sorry for multipost.

    • #5656
      notaname
      Member

      Ok, after upgrade Piklisk to 0.9.9 (https://piklist.com/2015/10/06/piklist-v0-9-9-public-beta-and-next-steps/), code above started working, also in this version field ‘editor’ witch ‘add_more’ work correct.

    • #5658
      Steve
      Keymaster

      @notaname– sorry we missed this ticket. But I’m glad you solved it.

      Closing ticket.

Viewing 5 reply threads
  • The topic ‘If at least one field should be hidden by condition whole metabox not displayed’ is closed to new replies.