1 form_example_tutorial.inc form_example_tutorial_1($form, &$form_state)

This is Example 1, a very basic form with a textfield.

This function is called the "form constructor function". It builds the form. It takes a two arguments, $form and $form_state, but if backdrop_get_form() sends additional arguments, they will be provided after $form_state.

Related topics

File

modules/examples/form_example/form_example_tutorial.inc, line 39
This is the form API tutorial.

Code

function form_example_tutorial_1($form, &$form_state) {

  $form['description'] = array(
    '#type' => 'item',
    '#title' => t('A form with nothing but a textfield'),
  );
  // This is the first form element. It's a textfield with a label, "Name"
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
  );
  return $form;
}