function form_test_pattern_form

Builds a simple form using the FAPI #pattern proterty.

1 string reference to 'form_test_pattern_form'
form_test_menu in drupal/core/modules/system/tests/modules/form_test/form_test.module
Implements hook_menu().

File

drupal/core/modules/system/tests/modules/form_test/form_test.module, line 656
Helper module for the form API tests.

Code

function form_test_pattern_form($form, &$form_state) {
  $form['textfield'] = array(
    '#type' => 'textfield',
    '#title' => 'One digit followed by lowercase letters',
    '#pattern' => '[0-9][a-z]+',
  );
  $form['tel'] = array(
    '#type' => 'tel',
    '#title' => 'Everything except numbers',
    '#pattern' => '[^\\d]*',
  );
  $form['password'] = array(
    '#type' => 'password',
    '#title' => 'Password',
    '#pattern' => '[01]+',
  );
  $form['url'] = array(
    '#type' => 'url',
    '#title' => 'Client side validation',
    '#decription' => 'Just client side validation, using the #pattern attribute.',
    '#attributes' => array(
      'pattern' => '.*foo.*',
    ),
    '#pattern' => 'ignored',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );
  return $form;
}