Submitted by Marvine on
Salut !
J'ai crée un module pour ajouter un champ à un de mes types de contenu en utilisant hook_form_alter.
Mon champ est de type checkboxes et contient un certain nombre de valeurs pour lesquelles j'aimerais modifier leurs attributs (id, name , value...)
J'utilise :
<?php $form['monchamp']['#attributes']= array('id' => 'new-id'); ?>
Cela fonctionne mais l'ancien id sous la forme edit-monchamp-n est conservé... Je me retrouve donc avec 2 fois l'attribut id !
<input type="checkbox" name="monchamp[1]" id="edit-monchamp-1" value="1" class="form-checkbox" />
La documentation ne m'aidant pas beaucoup
http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.... :
<?php
$form['#attributes'] = array('class' => 'search-form');
?>
Note: If you are altering an existing form via hook_form_alter() or a similar means, be careful with this property! You will probably want to add to the existing array rather than writing over it, so don't follow this usage example exactly.
Auriez-vous une idée ?