Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $form['name'] => array(
- '#type' => 'textfield',
- '#title' => 'Prénom'
- );
- $form['name']['#attributes']['class'] = array('myClass');
- $form['name'] => array(
- '#type' => 'textfield',
- '#title' => 'Prénom'
- '#prefix' => '<div class="myClass">',
- '#suffix' => '</div>'
- );
- .myClass label {
- text-transform: uppercase; /* just for example */
- }
- .form-item-field-foo label {
- /* CSS here */
- }
- function mymodule_form_alter(&$form, $form_state, $form_id) {
- switch ($form_id) {
- // Waterfall.
- case 'webform_client_form_16':
- case 'webform_client_form_51':
- case 'webform_client_form_64':
- case 'webform_client_form_78':
- $exclude = array('select', 'radios', 'checkboxes', 'managed_file');
- foreach ($form['submitted'] as $name => $component) {
- if (!in_array($component['#type'], $exclude) && $name != '#tree') {
- $form['submitted'][$name]['#prefix'] = '<span class= "label-invisible">';
- $form['submitted'][$name]['#suffix'] = '</span>';
- $form['submitted'][$name]['#attributes']['placeholder'] = $component['#title'];
- }
- }
- $form['#attached']['css'] = array(
- drupal_get_path('module', 'mymodule') . '/css/mymodule.form.css',
- );
- break;
- }
- }
- <span class="field-label"<?php print $title_attributes; ?>>
- <?php print $label; ?>:
- </span>
- <span class="<?php print $label; ?> field-label"<?php print $title_attributes; ?>>
- <?php print $label; ?>:
- </span>
- $form['some_element'] = array(
- '#type' => 'textfield',
- '#title' => '<span title="HELP!">'.t($subchildlabel).'</span>',
- '#default_value' => …
- )
- …
- );
- <label for="edit-m-vernacularname" class="inline"><span title="HELP!">Common name
- </span> </label>
- function your_module_preprocess_form_element(&$variables) {
- $element = $variables['element'];
- if (isset($element['#label_attributes'])) {
- $variables['label']['#attributes'] = array_merge(
- $variables['attributes'],
- $element['#label_attributes']
- );
- }
- }
- $form['some_field'] = [
- [...]
- '#label_attributes' => [
- 'some_attr' => 'some_value',
- ]
- ]
Add Comment
Please, Sign In to add comment