#prefix and #suffix in FORM API

Public

define multiple columns within form fields

Get raw version
php
  1. /**
  2.  * Implementation of hook_form_alter()
  3.  */
  4. function YOURTHEME_form_alter(&$form, &$form_state, $form_id) {
  5. switch($form_id) {
  6. case 'FORM_ID':
  7. $form['field-one']['#prefix'] = '<div class="first-column">';
  8. $form['field-two']['#suffix'] = '</div>';
  9. $form['field-three']['#prefix'] = '<div class="second-column">';
  10. $form['field-four']['#suffix'] = '</div>';
  11. break;
  12. }

Comments

mtubis's picture

It seems, that opening HTML tag in one form field and closing in another one doesn't work. At least, it doesn't work for me (Drupal 7). In similar case I used '#markup' as field before and after some fields.