Jump to content

Edit History

Pedro Lima

Pedro Lima


SOLVED

	$some_options = array(
            array(
                'id_option' => 'optone',
                'name' => $this->l('Option 1')
            ),
            array(
                'id_option' => 'opttwo',
                'name' => $this->l('Option 2')
            ),
        );

        $fields_form = array(
            'form' => array(
                'legend' => array(
                    'title' => $this->l('This is the title'),
                    'icon' => 'icon-cogs'
                ),
                'description' => $this->l('Here the description...'),
                'input' => array(
                    array(
                        'type' => 'switch',
                        'is_bool' => true, //retro-compat
                        'label' => $this->l('Enable'),
                        'name' => 'BTN_ENABLE_0',
                        'values' => array(
                            array(
                                'id' => 'active_on',
                                'value' => 1,
                                'label' => $this->l('Enabled')
                            ),
                            array(
                                'id' => 'active_off',
                                'value' => 0,
                                'label' => $this->l('Disabled')
                            )
                        ),
                    ),
                    array(
                        'type' => 'select',
                        'lang' => true,
                        'label' => $this->l('Select an Option'),
                        'name' => 'SELECT_OPT',
                        'desc' => $this->l('Just select the option...'),
                        'options' => array(
                            'query' => $some_options,
                            'id' => 'id_option',
                            'name' => 'name'
                        )
                    ),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Username'),
                        'name' => 'USERNAME',
                        'suffix' => 'USER',
                    ),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Password'),
                        'name' => 'PASSWORD',
                        'suffix' => 'SECRET',
                    ),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Some Code'),
                        'name' => 'SOME_CODE',
                        'suffix' => 'CODE',
                    ),
                    array(
                        'type' => 'desc',
                        'name' => '',
                        'text' => $this->l('And here another random text or whatever...')
                    ),
                ),
                'submit' => array(
                    'title' => $this->l('Save'),
                    'class' => 'btn btn-default pull-right'
                )
            ),
        );

So I have this code and I want to show "Username" and "Password" fields only when I have "Option 1" selected and hide "Some Code" field.

Then the oposite when "Option 2" is selected. Hide both "Username" and "Password" fields and show "Some Code" field.

And that's it, I've already googled, searched here inside forum and just can't find the answer, which I believe to be something simple.

Thank you very much in advance.

Pedro Lima

Pedro Lima

	$some_options = array(
            array(
                'id_option' => 'optone',
                'name' => $this->l('Option 1')
            ),
            array(
                'id_option' => 'opttwo',
                'name' => $this->l('Option 2')
            ),
        );

        $fields_form = array(
            'form' => array(
                'legend' => array(
                    'title' => $this->l('This is the title'),
                    'icon' => 'icon-cogs'
                ),
                'description' => $this->l('Here the description...'),
                'input' => array(
                    array(
                        'type' => 'switch',
                        'is_bool' => true, //retro-compat
                        'label' => $this->l('Enable'),
                        'name' => 'BTN_ENABLE_0',
                        'values' => array(
                            array(
                                'id' => 'active_on',
                                'value' => 1,
                                'label' => $this->l('Enabled')
                            ),
                            array(
                                'id' => 'active_off',
                                'value' => 0,
                                'label' => $this->l('Disabled')
                            )
                        ),
                    ),
                    array(
                        'type' => 'select',
                        'lang' => true,
                        'label' => $this->l('Select an Option'),
                        'name' => 'SELECT_OPT',
                        'desc' => $this->l('Just select the option...'),
                        'options' => array(
                            'query' => $some_options,
                            'id' => 'id_option',
                            'name' => 'name'
                        )
                    ),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Username'),
                        'name' => 'USERNAME',
                        'suffix' => 'USER',
                    ),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Password'),
                        'name' => 'PASSWORD',
                        'suffix' => 'SECRET',
                    ),
                    array(
                        'type' => 'text',
                        'label' => $this->l('Some Code'),
                        'name' => 'SOME_CODE',
                        'suffix' => 'CODE',
                    ),
                    array(
                        'type' => 'desc',
                        'name' => '',
                        'text' => $this->l('And here another random text or whatever...')
                    ),
                ),
                'submit' => array(
                    'title' => $this->l('Save'),
                    'class' => 'btn btn-default pull-right'
                )
            ),
        );

So I have this code and I want to show "Username" and "Password" fields only when I have "Option 1" selected and hide "Some Code" field.

Then the oposite when "Option 2" is selected. Hide both "Username" and "Password" fields and show "Some Code" field.

And that's it, I've already googled, searched here inside forum and just can't find the answer, which I believe to be something simple.

Thank you very much in advance.

×
×
  • Create New...