diff --git a/modules/form_response/form_response.info b/modules/form_response/form_response.info new file mode 100644 index 0000000..f017495 --- /dev/null +++ b/modules/form_response/form_response.info @@ -0,0 +1,2 @@ +name = Form response +core = 8.x diff --git a/modules/form_response/form_response.module b/modules/form_response/form_response.module new file mode 100644 index 0000000..afaf2c1 --- /dev/null +++ b/modules/form_response/form_response.module @@ -0,0 +1,52 @@ + 'Form response', + 'page callback' => 'form_response_callback', + 'access arguments' => array('access content'), + ); + + $item['form'] = array( + 'title' => 'Form response', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('form_response_form'), + 'access arguments' => array('access content'), + ); + + return $item; +} + +function form_response_callback() { + $form = drupal_get_form('form_response_form'); + $string = drupal_render($form); + $response = new Response($string); + return $response; +} + +function form_response_form($form, &$form_state) { + $form['select_element'] = array( + '#title' => t('Select'), + '#type' => 'select', + '#options' => array( + 'foo' => t('Foo'), + 'bar' => t('Boo'), + ), + ); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit'), + ); + + return $form; +} + +function form_response_form_submit($form, &$form_state) { + drupal_set_message($form_state['values']['select_element']); +} diff --git a/modules/form_response/lib/Drupal/form_response/Tests/FormResponseTest.php b/modules/form_response/lib/Drupal/form_response/Tests/FormResponseTest.php new file mode 100644 index 0000000..3b9a59c --- /dev/null +++ b/modules/form_response/lib/Drupal/form_response/Tests/FormResponseTest.php @@ -0,0 +1,33 @@ + 'Select Test', + 'description' => "foo", + 'group' => 'Select test', + ); + } + + public function testSelect() { + $this->drupalGet('form_response'); + $this->drupalPost('form_response', array('select_element' => 'foo'), t('Submit')); + $this->assertText('foo'); + + $this->drupalGet('form'); + $this->drupalPost('form', array('select_element' => 'foo'), t('Submit')); + $this->assertText('foo'); + } + +}