Jump to content

Display input text box by selecting dropdown list in my modules configuration at back-office


Recommended Posts

hello 

     I want to display or hide some of fields according to change the drop down list in my modules configuration page at back-office, 

 

for i.e  if select "student" in drop down then display label and input of "Course",

else if select "employee " then display "department".

Edited by NishantVadgama (see edit history)
Link to comment
Share on other sites

 

 

  public function renderForm()

  {

    $fields_form = array(

      'form' => array(

        'legend' => array(

          'title' => $this->l('My ModuleSettings'),

          'icon' => 'icon-cogs'

        ),

        'input' => array(

          array(

            'type' => 'text',

            'label' => $this->l('Site Url'),

            'name' => 'YOUR_NAME',

            'desc' => $this->l('Enter Your Name'),

            'lang' => true,

          ),

          array(

            'type' => 'select',

            'lang' => true,

            'label' => $this->l('Link Target'),

            'name' => 'WEBSITE_LINK_TARGET',

            'desc' => $this->l('Please Eneter Web Site URL Address.'),

            'options' => array(

              'query' => $options,

              'id' => 'id_option', 

              'name' => 'name'

            ),

            $options = array(

              array(

                'id_option' => 1, 

                'name' => 'Method 1' 

              ),

              array(

                'id_option' => 2,

                'name' => 'Method 2'

              ),

          )

          ),

        'submit' => array(

          'title' => $this->l('Save')

        )

      ),

    );

    

    $helper = new HelperForm();

    $helper->show_toolbar = true;

$helper->table =  $this->table;

    $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));

    $helper->default_form_language = $lang->id;

    $helper->module = $this;

    $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;

    $helper->identifier = $this->identifier;

    $helper->submit_action = 'submitmymoduleconf';

    $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;

    $helper->token = Tools::getAdminTokenLite('AdminModules');

$helper->tpl_vars = array(

'uri' => $this->getPathUri(),

'fields_value' => $this->getConfigFieldsValues(),

'languages' => $this->context->controller->getLanguages(),

'id_language' => $this->context->language->id

);

    return $helper->generateForm(array($fields_form));

  }

 how to write if condition and check if select "method 1" then show label & input dependent of method 1 and select "method 2" then call method 2's input respectively 

Edited by NishantVadgama (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...