dbtng_example_form_add

7 dbtng_example.module dbtng_example_form_add($form, &$form_state)
8 dbtng_example.module dbtng_example_form_add($form, &$form_state)

Prepare a simple form to add an entry, with all the interesting fields.

Related topics

1 string reference to 'dbtng_example_form_add'

File

dbtng_example/dbtng_example.module, line 420
This is an example outlining how a module can make use of the new DBTNG database API in Drupal 7.

Code

function dbtng_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 with DTBNG."),
  );
  $form['add']['submit'] = array(
    '#type' => 'submit', 
    '#value' => t('Add'),
  );

  return $form;
}
Login or register to post comments