function form_example_tutorial_1

Tutorial Example 1.

This first form function is from the Form Tutorial handbook page

It just creates 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 drupal_get_form() sends additional arguments, they will be provided after $form_state.

Related topics

1 string reference to 'form_example_tutorial_1'
form_example_menu in form_example/form_example.module
Implements hook_menu().

File

form_example/form_example_tutorial.inc, line 49

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;
}