Quantcast
Channel: Question and Answer » input-formats
Viewing all articles
Browse latest Browse all 27

Form always visible even when radiobutton value is changed (form api)

$
0
0

i’m having an issue with the property #states visible on a form.

I want to hide it when form mercuriale’s value is 1.

$isMercuriale = db_query('SELECT isMercuriale FROM groupes_catalogues WHERE id = ' . $idCatalogue)->fetchField();

  $form['mercuriale'] = array(
    '#type' => 'radios',
    '#title' => t('Type de catalogue'),
    '#default_value' => $isMercuriale,
    '#options' => array(
      '0' => t('Classique'), 
      '1' => t('Mercuriale'),
    ),
  );

  /* Secteurs */
  $listeSecteurs = db_query('SELECT tid, name AS nom FROM taxonomy_term_data WHERE vid = 7 ORDER BY nom');
  $header = array(
    'nom' => t('Secteur'),
    //'reduc' => t('Réduction (%)'),
    //'option' => t('Statut'),
  );

  $options = array();
  foreach($listeSecteurs as $secteur)
  {
    $options[$secteur->tid] = createFieldsCatalogue('secteurs', $secteur->tid, $secteur->nom, $idCatalogue);
  }
  $form['secteurs'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#default_value' => $uid,
    '#states' => array(
      'visible' => array(
        ':input[name="mercuriale"]' => array('value' => 0),
      ),
    ),
  );

What am I missing ?
Thank you.


Viewing all articles
Browse latest Browse all 27

Latest Images

Trending Articles



Latest Images