3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /** * Implements hook_menu */ function myownform_menu() { $items = array(); $items['myownform'] = array( 'title' => 'My Own Form', 'type' => MENU_NORMAL_ITEM, 'access arguments' => array('submit myownform'), 'page callback' => 'drupal_get_form', 'page arguments' => array('myownform_form'), ); return $items; } /** * Implements hook_form */ function myownform_form($form, &$form_state) { $form['myowntext'] = array( '#type' => 'textfield', '#title' => t('My own Text'), '#size' => 50, '#maxlength' => 50, '#required' => TRUE, '#description' => t('Please enter a small text'), ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit') ); return $form; } /** * Validation handler for the myownform_form */ function myownform_form_validate($form, &$form_state) { if (!isset($form_state['values']['myowntext'])) { form_set_error('myowntext', t('You must enter a value.')); return FALSE; } return TRUE; } /** * Submission handler for the myownform_form */ function myownform_form_submit($form, &$form_state) { $form_state['rebuild'] = TRUE; print($_POST['myowntext']); } ?>
Output for 4.3.0 - 7.2.0