1 database_example.module | database_example_form_add($form, &$form_state) |
Prepares a simple form to add an entry, with all the interesting fields.
Related topics
File
- modules/
examples/ database_example/ database_example.module, line 356 - Hook implementations for the Database Example module.
Code
function database_example_form_add($form, &$form_state) {
$form = array();
$form['add'] = array(
'#type' => 'fieldset',
'#title' => t('Add a person entry'),
);
$form['add']['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 15,
);
$form['add']['surname'] = array(
'#type' => 'textfield',
'#title' => t('Surname'),
'#size' => 15,
);
$form['add']['age'] = array(
'#type' => 'textfield',
'#title' => t('Age'),
'#size' => 5,
'#description' => t("Values greater than 127 will cause an exception. Try it; it's a great example why exception handling is needed."),
);
$form['add']['submit'] = array(
'#type' => 'submit',
'#value' => t('Add'),
);
return $form;
}