Need – Required or Dependency options for fields.

Asked on October 20, 2015 in Feature Requests.

Hi,

I’m developing the Layers Extension Magic Box. At the time of development, I need the Required or Dependency options for form fields.

E.g. If I add a dropdown with some options. And other fields are dependent on the selected dropdown option. I.e.

– OPTION-1 – If selected, I’ll show any TWO fields
– OPTION-2 – Has any other THREE fields as per my requirement.

We will hide these options by using jQuery. Like Redux & Visual Composer has options Required or Dependency. I was tried to build it but due to other stuff, I was not build it. Just sending this idea for future release.

So, We will set the dependencies of other fields.

This is just for better user interface & it help a lot to develop structured options.

Another real example, I have a drop down.

i.e. divider_type with options Icon & Image.
– If user select Icon. Then, I’ll show Icon font dropdown list
– If user select Image. Then, I’ll show Image uploader

Screenshots: https://qas-shared-assets.s3.amazonaws.com/snaps/gvjre5tat51m7vi

mwaghmare7 Developer
Reply
  • Possible Answers to Your Question:

  • 1 Answer(s)
    Answered on November 3, 2015.

    Yep!

    Added dependency for layer fields. Now, Working for select field. Need to test with other fields too.

    Working git repository. Git Commit ID – e1f8564e76149ecba842a8a3a0c214a4d31398fc

    >*How to:*

    
    <p class="layers-form-item">
    
    <?php echo $this->form_elements()->input(
    
    array(
    
    'type' => 'select',
    
    'label' => __( 'Option - 1' , 'layerswp' ),
    
    'name' => 'Option 1',
    
    'id' => 'option-1',
    
    'value' => NULL,
    
    'options' => array(
    
    '1' => __( 'Option 1' , 'layerswp' ),
    
    '2' => __( 'Option 2' , 'layerswp' ),
    
    '3' => __( 'Option 3' , 'layerswp' ),
    
    )
    
    )
    
    );
    
    ?>
    
    </p>
    
    <p class="layers-form-item">
    
    <?php echo $this->form_elements()->input(
    
    array(
    
    'type' => 'select',
    
    'label' => __( 'Option - 2' , 'layerswp' ),
    
    'name' => 'Option 2',
    
    'id' => 'option-2',
    
    'value' => NULL,
    
    'options' => array(
    
    '4' => __( 'Option 4' , 'layerswp' ),
    
    '5' => __( 'Option 5' , 'layerswp' ),
    
    '6' => __( 'Option 6' , 'layerswp' ),
    
    ),
    
    'dependency' => array( 'option-1', '!=', '2' ),
    
    )
    
    );
    
    ?>
    
    </p>
    
    

    Here,
    – Added dependency for option-2. I.e. If field Option-1 is not containing selected value 2.
    – Showing for Option – 1 values 1 or 3
    – Hidden for value 2

    >*Screenshot:*

    Reply