'Form altering test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_alter_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form-test/validate'] = array( 'title' => 'Form validation handlers test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_validate_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form-test/validate-required'] = array( 'title' => 'Form #required validation', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_validate_required_form'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form-test/validate-required-no-title'] = array( 'title' => 'Form #required validation without #title', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_validate_required_form_no_title'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form-test/limit-validation-errors'] = array( 'title' => 'Form validation with some error suppression', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_limit_validation_errors_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form_test/tableselect/multiple-true'] = array( 'title' => 'Tableselect checkboxes test', 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_tableselect_multiple_true_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form_test/tableselect/multiple-false'] = array( 'title' => 'Tableselect radio button test', 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_tableselect_multiple_false_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form_test/tableselect/empty-text'] = array( 'title' => 'Tableselect empty text test', 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_tableselect_empty_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form_test/tableselect/advanced-select'] = array( 'title' => 'Tableselect js_select tests', 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_tableselect_js_select_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form_test/vertical-tabs'] = array( 'title' => 'Vertical tabs tests', 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_vertical_tabs_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form_test/form-storage'] = array( 'title' => 'Form storage test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_storage_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form_test/form-storage-legacy'] = array( 'title' => 'Emulate legacy AHAH-style ajax callback', 'page callback' => 'form_test_storage_legacy_handler', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form_test/form-storage-page-cache'] = array( 'title' => 'Form storage with page cache test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_storage_page_cache_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form_test/wrapper-callback'] = array( 'title' => 'Form wrapper callback test', 'page callback' => 'form_test_wrapper_callback', 'page arguments' => array('form_test_wrapper_callback_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form_test/form-state-values-clean'] = array( 'title' => 'Form state values clearance test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_form_state_values_clean_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form_test/form-state-values-clean-advanced'] = array( 'title' => 'Form state values clearance advanced test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_form_state_values_clean_advanced_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form-test/checkbox'] = array( 'title' => t('Form test'), 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_checkbox'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form-test/select'] = array( 'title' => t('Select'), 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_select'), 'access callback' => TRUE, ); $items['form-test/checkboxes-radios'] = array( 'title' => t('Checkboxes, Radios'), 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_checkboxes_radios'), 'access callback' => TRUE, ); $items['form-test/disabled-elements'] = array( 'title' => t('Form test'), 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_disabled_elements'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form-test/input-forgery'] = array( 'title' => t('Form test'), 'page callback' => 'drupal_get_form', 'page arguments' => array('_form_test_input_forgery'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form-test/form-rebuild-preserve-values'] = array( 'title' => 'Form values preservation during rebuild test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_form_rebuild_preserve_values_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form-test/redirect'] = array( 'title' => 'Redirect test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_redirect'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form_test/form-labels'] = array( 'title' => 'Form label test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_label_test_form'), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); $items['form-test/state-persist'] = array( 'title' => 'Form state persistence without storage', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_state_persist'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form-test/clicked-button'] = array( 'title' => 'Clicked button test', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_clicked_button'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); if (module_exists('node')) { $items['form-test/two-instances-of-same-form'] = array( 'title' => 'AJAX test with two form instances', 'page callback' => 'form_test_two_instances', 'access callback' => 'node_access', 'access arguments' => array('create', 'page'), 'file path' => drupal_get_path('module', 'node'), 'file' => 'node.pages.inc', 'type' => MENU_CALLBACK, ); } $items['form-test/double-form'] = array( 'title' => 'Double form test', 'page callback' => 'form_test_double_form', 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form-test/load-include-menu'] = array( 'title' => 'FAPI test loading includes', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_load_include_menu'), 'access callback' => TRUE, 'file' => 'form_test.file.inc', 'type' => MENU_CALLBACK, ); $items['form-test/load-include-custom'] = array( 'title' => 'FAPI test loading includes', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_load_include_custom'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['form-test/checkboxes-zero'] = array( 'title' => 'FAPI test involving checkboxes and zero', 'page callback' => 'drupal_get_form', 'page arguments' => array('form_test_checkboxes_zero'), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); return $items; } /** * Form submit handler to return form values as JSON. */ function _form_test_submit_values_json($form, &$form_state) { drupal_json_output($form_state['values']); drupal_exit(); } /** * Form builder for testing hook_form_alter() and hook_form_FORM_ID_alter(). */ function form_test_alter_form($form, &$form_state) { // Elements can be added as needed for future testing needs, but for now, // we're only testing alter hooks that do not require any elements added by // this function. return $form; } /** * Implements hook_form_FORM_ID_alter() on behalf of block.module. */ function block_form_form_test_alter_form_alter(&$form, &$form_state) { drupal_set_message('block_form_form_test_alter_form_alter() executed.'); } /** * Implements hook_form_alter(). */ function form_test_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'form_test_alter_form') { drupal_set_message('form_test_form_alter() executed.'); } } /** * Implements hook_form_FORM_ID_alter(). */ function form_test_form_form_test_alter_form_alter(&$form, &$form_state) { drupal_set_message('form_test_form_form_test_alter_form_alter() executed.'); } /** * Implements hook_form_FORM_ID_alter() on behalf of system.module. */ function system_form_form_test_alter_form_alter(&$form, &$form_state) { drupal_set_message('system_form_form_test_alter_form_alter() executed.'); } /** * Form builder for testing drupal_validate_form(). * * Serves for testing form processing and alterations by form validation * handlers, especially for the case of a validation error: * - form_set_value() should be able to alter submitted values in * $form_state['values'] without affecting the form element. * - #element_validate handlers should be able to alter the $element in the form * structure and the alterations should be contained in the rebuilt form. * - #validate handlers should be able to alter the $form and the alterations * should be contained in the rebuilt form. */ function form_test_validate_form($form, &$form_state) { $form['name'] = array( '#type' => 'textfield', '#title' => 'Name', '#default_value' => '', '#element_validate' => array('form_test_element_validate_name'), ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Save', ); // To simplify this test, enable form caching and use form storage to // remember our alteration. $form_state['cache'] = TRUE; return $form; } /** * Form element validation handler for 'name' in form_test_validate_form(). */ function form_test_element_validate_name(&$element, &$form_state) { $triggered = FALSE; if ($form_state['values']['name'] == 'element_validate') { // Alter the form element. $element['#value'] = '#value changed by #element_validate'; // Alter the submitted value in $form_state. form_set_value($element, 'value changed by form_set_value() in #element_validate', $form_state); $triggered = TRUE; } if ($form_state['values']['name'] == 'element_validate_access') { $form_state['storage']['form_test_name'] = $form_state['values']['name']; // Alter the form element. $element['#access'] = FALSE; $triggered = TRUE; } elseif (!empty($form_state['storage']['form_test_name'])) { // To simplify this test, just take over the element's value into $form_state. form_set_value($element, $form_state['storage']['form_test_name'], $form_state); $triggered = TRUE; } if ($triggered) { // Output the element's value from $form_state. drupal_set_message(t('@label value: @value', array('@label' => $element['#title'], '@value' => $form_state['values']['name']))); // Trigger a form validation error to see our changes. form_set_error(''); } } /** * Form validation handler for form_test_validate_form(). */ function form_test_validate_form_validate(&$form, &$form_state) { if ($form_state['values']['name'] == 'validate') { // Alter the form element. $form['name']['#value'] = '#value changed by #validate'; // Alter the submitted value in $form_state. form_set_value($form['name'], 'value changed by form_set_value() in #validate', $form_state); // Output the element's value from $form_state. drupal_set_message(t('@label value: @value', array('@label' => $form['name']['#title'], '@value' => $form_state['values']['name']))); // Trigger a form validation error to see our changes. form_set_error(''); } } /** * Form constructor to test the #required property. */ function form_test_validate_required_form($form, &$form_state) { $options = drupal_map_assoc(array('foo', 'bar')); $form['textfield'] = array( '#type' => 'textfield', '#title' => 'Textfield', '#required' => TRUE, ); $form['checkboxes'] = array( '#type' => 'checkboxes', '#title' => 'Checkboxes', '#options' => $options, '#required' => TRUE, ); $form['select'] = array( '#type' => 'select', '#title' => 'Select', '#options' => $options, '#required' => TRUE, ); $form['radios'] = array( '#type' => 'radios', '#title' => 'Radios', '#options' => $options, '#required' => TRUE, ); $form['radios_optional'] = array( '#type' => 'radios', '#title' => 'Radios (optional)', '#options' => $options, ); $form['radios_optional_default_value_false'] = array( '#type' => 'radios', '#title' => 'Radios (optional, with a default value of FALSE)', '#options' => $options, '#default_value' => FALSE, ); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Submit'); return $form; } /** * Form submission handler for form_test_validate_required_form(). */ function form_test_validate_required_form_submit($form, &$form_state) { drupal_set_message('The form_test_validate_required_form form was submitted successfully.'); } /** * Form constructor to test the #required property without #title. */ function form_test_validate_required_form_no_title($form, &$form_state) { $form['textfield'] = array( '#type' => 'textfield', '#required' => TRUE, ); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Submit'); return $form; } /** * Form submission handler for form_test_validate_required_form_no_title(). */ function form_test_validate_required_form_no_title_submit($form, &$form_state) { drupal_set_message('The form_test_validate_required_form_no_title form was submitted successfully.'); } /** * Builds a simple form with a button triggering partial validation. */ function form_test_limit_validation_errors_form($form, &$form_state) { $form['title'] = array( '#type' => 'textfield', '#title' => 'Title', '#required' => TRUE, ); $form['test'] = array( '#title' => 'Test', '#type' => 'textfield', '#element_validate' => array('form_test_limit_validation_errors_element_validate_test'), ); $form['test_numeric_index'] = array( '#tree' => TRUE, ); $form['test_numeric_index'][0] = array( '#title' => 'Test (numeric index)', '#type' => 'textfield', '#element_validate' => array('form_test_limit_validation_errors_element_validate_test'), ); $form['test_substring'] = array( '#tree' => TRUE, ); $form['test_substring']['foo'] = array( '#title' => 'Test (substring) foo', '#type' => 'textfield', '#element_validate' => array('form_test_limit_validation_errors_element_validate_test'), ); $form['test_substring']['foobar'] = array( '#title' => 'Test (substring) foobar', '#type' => 'textfield', '#element_validate' => array('form_test_limit_validation_errors_element_validate_test'), ); $form['actions']['partial'] = array( '#type' => 'submit', '#limit_validation_errors' => array(array('test')), '#submit' => array('form_test_limit_validation_errors_form_partial_submit'), '#value' => t('Partial validate'), ); $form['actions']['partial_numeric_index'] = array( '#type' => 'submit', '#limit_validation_errors' => array(array('test_numeric_index', 0)), '#submit' => array('form_test_limit_validation_errors_form_partial_submit'), '#value' => t('Partial validate (numeric index)'), ); $form['actions']['substring'] = array( '#type' => 'submit', '#limit_validation_errors' => array(array('test_substring', 'foo')), '#submit' => array('form_test_limit_validation_errors_form_partial_submit'), '#value' => t('Partial validate (substring)'), ); $form['actions']['full'] = array( '#type' => 'submit', '#value' => t('Full validate'), ); return $form; } /** * Form element validation handler for the 'test' element. */ function form_test_limit_validation_errors_element_validate_test(&$element, &$form_state) { if ($element['#value'] == 'invalid') { form_error($element, t('@label element is invalid', array('@label' => $element['#title']))); } } /** * Form submit handler for the partial validation submit button. */ function form_test_limit_validation_errors_form_partial_submit($form, $form_state) { // The title has not been validated, thus its value - in case of the test case // an empty string - may not be set. if (!isset($form_state['values']['title']) && isset($form_state['values']['test'])) { drupal_set_message('Only validated values appear in the form values.'); } } /** * Create a header and options array. Helper function for callbacks. */ function _form_test_tableselect_get_data() { $header = array( 'one' => t('One'), 'two' => t('Two'), 'three' => t('Three'), 'four' => t('Four'), ); $options['row1'] = array( 'one' => 'row1col1', 'two' => t('row1col2'), 'three' => t('row1col3'), 'four' => t('row1col4'), ); $options['row2'] = array( 'one' => 'row2col1', 'two' => t('row2col2'), 'three' => t('row2col3'), 'four' => t('row2col4'), ); $options['row3'] = array( 'one' => 'row3col1', 'two' => t('row3col2'), 'three' => t('row3col3'), 'four' => t('row3col4'), ); return array($header, $options); } /** * Build a form to test the tableselect element. * * @param $form_state * The form_state * @param $element_properties * An array of element properties for the tableselect element. * * @return * A form with a tableselect element and a submit button. */ function _form_test_tableselect_form_builder($form, $form_state, $element_properties) { list($header, $options) = _form_test_tableselect_get_data(); $form['tableselect'] = $element_properties; $form['tableselect'] += array( '#type' => 'tableselect', '#header' => $header, '#options' => $options, '#multiple' => FALSE, '#empty' => t('Empty text.'), ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; } /** * Test the tableselect #multiple = TRUE functionality. */ function _form_test_tableselect_multiple_true_form($form, $form_state) { return _form_test_tableselect_form_builder($form, $form_state, array('#multiple' => TRUE)); } /** * Process the tableselect #multiple = TRUE submitted values. */ function _form_test_tableselect_multiple_true_form_submit($form, &$form_state) { $selected = $form_state['values']['tableselect']; foreach ($selected as $key => $value) { drupal_set_message(t('Submitted: @key = @value', array('@key' => $key, '@value' => $value))); } } /** * Test the tableselect #multiple = FALSE functionality. */ function _form_test_tableselect_multiple_false_form($form, $form_state) { return _form_test_tableselect_form_builder($form, $form_state, array('#multiple' => FALSE)); } /** * Process the tableselect #multiple = FALSE submitted values. */ function _form_test_tableselect_multiple_false_form_submit($form, &$form_state) { drupal_set_message(t('Submitted: @value', array('@value' => $form_state['values']['tableselect']))); } /** * Test functionality of the tableselect #empty property. */ function _form_test_tableselect_empty_form($form, $form_state) { return _form_test_tableselect_form_builder($form, $form_state, array('#options' => array())); } /** * Test functionality of the tableselect #js_select property. */ function _form_test_tableselect_js_select_form($form, $form_state, $action) { switch ($action) { case 'multiple-true-default': $options = array('#multiple' => TRUE); break; case 'multiple-false-default': $options = array('#multiple' => FALSE); break; case 'multiple-true-no-advanced-select': $options = array('#multiple' => TRUE, '#js_select' => FALSE); break; case 'multiple-false-advanced-select': $options = array('#multiple' => FALSE, '#js_select' => TRUE); break; } return _form_test_tableselect_form_builder($form, $form_state, $options); } /** * Tests functionality of vertical tabs. */ function _form_test_vertical_tabs_form($form, &$form_state) { $form['vertical_tabs'] = array( '#type' => 'vertical_tabs', ); $form['tab1'] = array( '#type' => 'fieldset', '#title' => t('Tab 1'), '#collapsible' => TRUE, '#group' => 'vertical_tabs', ); $form['tab1']['field1'] = array( '#title' => t('Field 1'), '#type' => 'textfield', ); $form['tab2'] = array( '#type' => 'fieldset', '#title' => t('Tab 2'), '#collapsible' => TRUE, '#group' => 'vertical_tabs', ); $form['tab2']['field2'] = array( '#title' => t('Field 2'), '#type' => 'textfield', ); return $form; } /** * A multistep form for testing the form storage. * * It uses two steps for editing a virtual "thing". Any changes to it are saved * in the form storage and have to be present during any step. By setting the * request parameter "cache" the form can be tested with caching enabled, as * it would be the case, if the form would contain some #ajax callbacks. * * @see form_test_storage_form_submit() */ function form_test_storage_form($form, &$form_state) { if ($form_state['rebuild']) { $form_state['input'] = array(); } // Initialize if (empty($form_state['storage'])) { if (empty($form_state['input'])) { $_SESSION['constructions'] = 0; } // Put the initial thing into the storage $form_state['storage'] = array( 'thing' => array( 'title' => 'none', 'value' => '', ), ); } // Count how often the form is constructed. $_SESSION['constructions']++; drupal_set_message("Form constructions: " . $_SESSION['constructions']); $form['title'] = array( '#type' => 'textfield', '#title' => 'Title', '#default_value' => $form_state['storage']['thing']['title'], '#required' => TRUE, ); $form['value'] = array( '#type' => 'textfield', '#title' => 'Value', '#default_value' => $form_state['storage']['thing']['value'], '#element_validate' => array('form_test_storage_element_validate_value_cached'), ); $form['continue_button'] = array( '#type' => 'button', '#value' => 'Reset', // Rebuilds the form without keeping the values. ); $form['continue_submit'] = array( '#type' => 'submit', '#value' => 'Continue submit', '#submit' => array('form_storage_test_form_continue_submit'), ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Save', ); if (isset($_REQUEST['cache'])) { // Manually activate caching, so we can test that the storage keeps working // when it's enabled. $form_state['cache'] = TRUE; } if (isset($_REQUEST['immutable'])) { $form_state['build_info']['immutable'] = TRUE; } return $form; } /** * Emulate legacy AHAH-style ajax callback. * * Drupal 6 AHAH callbacks used to operate directly on forms retrieved using * form_get_cache and stored using form_set_cache after manipulation. This * callback helps testing whether form_set_cache prevents resaving of immutable * forms. */ function form_test_storage_legacy_handler($form_build_id) { $form_state = array(); $form = form_get_cache($form_build_id, $form_state); drupal_json_output(array( 'form' => $form, 'form_state' => $form_state, )); $form['#poisoned'] = TRUE; $form_state['poisoned'] = TRUE; form_set_cache($form_build_id, $form, $form_state); } /** * Form element validation handler for 'value' element in form_test_storage_form(). * * Tests updating of cached form storage during validation. */ function form_test_storage_element_validate_value_cached($element, &$form_state) { // If caching is enabled and we receive a certain value, change the storage. // This presumes that another submitted form value triggers a validation error // elsewhere in the form. Form API should still update the cached form storage // though. if (isset($_REQUEST['cache']) && $form_state['values']['value'] == 'change_title') { $form_state['storage']['thing']['changed'] = TRUE; } } /** * Form submit handler to continue multi-step form. */ function form_storage_test_form_continue_submit($form, &$form_state) { $form_state['storage']['thing']['title'] = $form_state['values']['title']; $form_state['storage']['thing']['value'] = $form_state['values']['value']; $form_state['rebuild'] = TRUE; } /** * Form submit handler to finish multi-step form. */ function form_test_storage_form_submit($form, &$form_state) { drupal_set_message("Title: " . check_plain($form_state['values']['title'])); drupal_set_message("Form constructions: " . $_SESSION['constructions']); if (isset($form_state['storage']['thing']['changed'])) { drupal_set_message("The thing has been changed."); } $form_state['redirect'] = 'node'; } /** * A simple form for testing form storage when page caching is enabled. */ function form_test_storage_page_cache_form($form, &$form_state) { $form['title'] = array( '#type' => 'textfield', '#title' => 'Title', '#required' => TRUE, ); $form['test_build_id_old'] = array( '#type' => 'item', '#title' => 'Old build id', '#markup' => 'No old build id', ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Save', ); $form['rebuild'] = array( '#type' => 'submit', '#value' => 'Rebuild', '#submit' => array('form_test_storage_page_cache_rebuild'), ); $form['#after_build'] = array('form_test_storage_page_cache_old_build_id'); $form_state['cache'] = TRUE; return $form; } /** * Form element #after_build callback: output the old form build-id. */ function form_test_storage_page_cache_old_build_id($form) { if (isset($form['#build_id_old'])) { $form['test_build_id_old']['#markup'] = check_plain($form['#build_id_old']); } return $form; } /** * Form submit callback: Rebuild the form and continue. */ function form_test_storage_page_cache_rebuild($form, &$form_state) { $form_state['rebuild'] = TRUE; } /** * A form for testing form labels and required marks. */ function form_label_test_form() { $form['form_checkboxes_test'] = array( '#type' => 'checkboxes', '#title' => t('Checkboxes test'), '#options' => array( 'first-checkbox' => t('First checkbox'), 'second-checkbox' => t('Second checkbox'), 'third-checkbox' => t('Third checkbox'), '0' => t('0'), ), ); $form['form_radios_test'] = array( '#type' => 'radios', '#title' => t('Radios test'), '#options' => array( 'first-radio' => t('First radio'), 'second-radio' => t('Second radio'), 'third-radio' => t('Third radio'), '0' => t('0'), ), // Test #field_prefix and #field_suffix placement. '#field_prefix' => '' . t('Radios #field_prefix element') . '', '#field_suffix' => '' . t('Radios #field_suffix element') . '', ); $form['form_checkbox_test'] = array( '#type' => 'checkbox', '#title' => t('Checkbox test'), ); $form['form_textfield_test_title_and_required'] = array( '#type' => 'textfield', '#title' => t('Textfield test for required with title'), '#required' => TRUE, ); $form['form_textfield_test_no_title_required'] = array( '#type' => 'textfield', // We use an empty title, since not setting #title suppresses the label // and required marker. '#title' => '', '#required' => TRUE, ); $form['form_textfield_test_title'] = array( '#type' => 'textfield', '#title' => t('Textfield test for title only'), // Not required. // Test #prefix and #suffix placement. '#prefix' => '