You are here

function form_builder_examples_example in Form Builder 7

Same name and namespace in other branches
  1. 6 examples/form_builder_examples.module \form_builder_examples_example()
  2. 7.2 examples/form_builder_examples.module \form_builder_examples_example()

A sample form array for testings.

1 call to form_builder_examples_example()
form_builder_examples_form_builder_load in examples/form_builder_examples.module
Implementation of hook_form_builder_load().

File

examples/form_builder_examples.module, line 56
form_builder_examples.module Sample implementations of form_builder.

Code

function form_builder_examples_example() {
  $form = array(
    'sample_textfield' => array(
      '#form_builder' => array(
        'element_id' => 'sample_textfield',
        'element_type' => 'textfield',
        'configurable' => TRUE,
        'removable' => TRUE,
      ),
      '#type' => 'textfield',
      '#title' => 'Sample textfield',
      '#default_value' => 'a sample value',
      '#field_prefix' => 'Prefix: ',
      '#field_suffix' => ' :Suffix',
      '#size' => 20,
      '#weight' => 0,
    ),
    'sample_checkboxes' => array(
      '#form_builder' => array(
        'element_id' => 'sample_checkboxes',
        'element_type' => 'checkboxes',
        'configurable' => TRUE,
        'removable' => TRUE,
      ),
      '#type' => 'checkboxes',
      '#title' => 'Sample checkboxes',
      '#options' => array(
        'one' => 'one',
        'two' => 'two',
        'three' => 'three',
      ),
      '#default_value' => array(
        'two',
      ),
      '#weight' => 1,
      '#multiple' => 1,
    ),
    'sample_textarea' => array(
      '#form_builder' => array(
        'element_id' => 'sample_textarea',
        'element_type' => 'textarea',
        'configurable' => TRUE,
        'removable' => TRUE,
      ),
      '#type' => 'textarea',
      '#title' => 'Sample textarea',
      '#default_value' => 'Text area sample value',
      '#weight' => 2,
    ),
    'sample_radios' => array(
      '#form_builder' => array(
        'element_id' => 'sample_radios',
        'element_type' => 'radios',
        'configurable' => TRUE,
        'removable' => TRUE,
      ),
      '#type' => 'radios',
      '#title' => 'Sample radios',
      '#options' => array(
        'one' => 'one',
        'two' => 'two',
        'three' => 'three',
      ),
      '#default_value' => 'two',
      '#weight' => 3,
    ),
    'sample_select' => array(
      '#form_builder' => array(
        'element_id' => 'sample_select',
        'element_type' => 'select',
        'configurable' => TRUE,
        'removable' => TRUE,
      ),
      '#type' => 'select',
      '#title' => 'Sample select',
      '#options' => array(
        'one' => 'one',
        'two' => 'two',
        'three' => 'three',
      ),
      '#default_value' => 'two',
      '#weight' => 4,
      '#multiple_toggle' => TRUE,
    ),
  );
  return $form;
}