Viewing 5 reply threads
  • Author
    Posts
    • #2641
      atanas
      Member

      Hi,

      Thanks a lot for the work you guys have put into this project.

      I am trying to have conditions in add more groups based on select fields (two of them per group). For example if the user selects an entry in the first select list, then I would like to show the appropriate child select list (its a basic parent/child relationship between the first and second select).

      In the current version, changing the selected value in one of the add more groups, updates all the select fields ln the other add more groups.

      Is there any other way to display such groups, or any suggested workaround

      Thanks
      Atanas

    • #2648
      Steve
      Keymaster

      @atanas– Please post your field code.

    • #2653
      atanas
      Member

      Hi Steve,

      Here is the code that demonstrates both the conditions in add more (if you have more than one addmore, selecting a fruit in one of them will force display the corresponding fruits in all of the add mores) and the misalignment when trying to put all the fields in one group (besides the conditions do not work when in a sub-group)

      
      piklist('field',
      	array('type' => 'group',
      	      'label' => 'Settings',
      		   "field" => "settings",
      	      'description' => 'Main Settings Field',
      	      'add_more' => false,
      	      'fields' => array(
      		array('type' => 'group',
      		      'label' => 'Fruits',
      		      'add_more' => true,
      		      'description' => 'Select a fruit.',
      		      'fields' => array(
      			      array(
      				      'type' => 'select',
      				      'field' => 'country',
      				      'label' => 'Country',
      				      'value' => 'US',
      				      'columns' => 4,
      				      'choices' => array(
      					      'US' => 'United States',
      					      'EU' => 'European Union'
      				      )
      			      ),
      
      			      array(
      				      'type' => 'select',
      				      'field' => 'fruits',
      				      'label' => 'Fruits',
      				      'value' => 'apples',
      				      'columns' => 12,
      				      'choices' => array(
      					      "apples" => "Apples",
      					      "oranges" => "Oranges",
      				      )
      			      ),
      
      			      array(
      				      'type' => 'select',
      				      'field' => 'apples',
      				      'label' => 'Apples',
      				      'columns' => 12,
      				      'value'   => 'post_title',
      				      'choices' => array(
      					      "aceymac" => 'Aceymac  apple',
      					      "akero" => 'Akero  apple',
      				      ),
      				      'conditions' => array(
      					      array(
      						      "reset" => false,
      						      'field' => 'fruits',
      						      'value' => "apples"
      					      ),
      
      				      )),
      			      array(
      				      'type' => 'select',
      				      'field' => 'oranges',
      				      'label' => 'Oranges',
      				      'columns' => 12,
      				      'choices' => array(
      					      "blood" => "Blood Orange",
      					      "navel" => "Navel Orange"
      				      ),
      				      'conditions' => array(
      					      array(
      						      "reset" => false,
      						      'field' => 'fruits',
      						      'value' => "oranges"
      					      ),
      
      				      )),
      		      ),
      			),
      		      array(
      			      'type' => 'select',
      			      'field' => 'shipping',
      			      'label' => 'Shipping',
      			      'columns' => 4,
      			      'choices' => array(
      				      ''          => '',
      				      'ground'  => 'Ground',
      				      'UPS'    => 'UPS',
      			      )
      
      		      ),
      
      	    ),
      	)
      );
      
    • #2658
      Steve
      Keymaster

      @atanas– Your code is throwing some warnings for me so it’s tough to debug.

      What exactly do you want to happen? Which fields should be within the add_more?

    • #2661
      atanas
      Member

      Hi steve,

      In the add more are the fields:

      Country – a select field
      Fruits – a select field
      Organges and apples – select fields with a condition based on the above fruits field ( is user selects organges as the fruit, we show the varieties of organges, if they select apples, we show the varieties of apples)

      Outside of the add more is the shipping field

      Thanks
      Atanas

    • #2662
      Steve
      Keymaster

      @atana– It was really tough to debug your code so I just wrote it from scratch. I also attached a screenshot so you can see what it should look like. Let me know if this works for you.

        piklist('field', array(
          'type' => 'group'
          ,'field' => 'atanas_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' => 'atanas_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' => 'atanas_settings:fruits'
                    ,'value' => 'oranges'
                  )
                )
              )
          )
        ));
      
      
        piklist('field', array(
          'type' => 'select'
          ,'field' => 'shipping'
          ,'label' => 'Shipping'
          ,'choices' => array(
            'ground' => 'Ground'
            ,'ups' => 'UPS'
          )
        ));
      
      Attachments:
      You must be logged in to view attached files.
Viewing 5 reply threads
  • The topic ‘Conditions in add more groups’ is closed to new replies.