diff --git a/core/modules/system/lib/Drupal/system/SystemConfigForm.php b/core/modules/system/lib/Drupal/system/SystemConfigForm.php new file mode 100644 index 0000000..d468605 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/SystemConfigForm.php @@ -0,0 +1,52 @@ + 'submit', + '#value' => t('Save configuration'), + '#button_type' => 'primary', + ); + + // By default, render the form using theme_system_settings_form(). + $form['#theme'] = 'system_settings_form'; + + return $form; + } + + /** + * Implements \Drupal\Core\Form\FormInterface::validateForm(). + */ + public function validateForm(array &$form, array &$form_state) {} + + /** + * Implements \Drupal\Core\Form\FormInterface::submitForm(). + */ + public function submitForm(array &$form, array &$form_state) { + drupal_set_message(t('The configuration options have been saved.')); + } + +} diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/SystemConfigFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/SystemConfigFormTest.php new file mode 100644 index 0000000..d361d55 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Form/SystemConfigFormTest.php @@ -0,0 +1,44 @@ + 'SystemConfigmForm tests', + 'description' => 'Tests the SystemConfigForm base class.', + 'group' => 'Form API', + ); + } + + /** + * Tests the SystemConfigForm base class. + */ + function testSystemConfigForm() { + $this->drupalGet('form-test/system-config-form'); + $element = $this->xpath('//div[@id = :id]/input[contains(@class, :class)]', array(':id' => 'edit-actions', ':class' => 'button-primary')); + $this->assertTrue($element, 'The primary action submit button was found.'); + $this->drupalPost(NULL, array(), t('Save configuration')); + $this->assertText(t('The configuration options have been saved.')); + } + +} diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module index f85fd6d..fe5d999 100644 --- a/core/modules/system/tests/modules/form_test/form_test.module +++ b/core/modules/system/tests/modules/form_test/form_test.module @@ -7,6 +7,7 @@ use Drupal\form_test\Callbacks; use Drupal\form_test\FormTestObject; +use Drupal\form_test\SystemConfigFormTestForm; use Drupal\Core\Datetime\DrupalDateTime; /** @@ -33,6 +34,12 @@ function form_test_menu() { 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); + $items['form-test/system-config-form'] = array( + 'title' => 'Form object builder test', + 'page callback' => 'form_test_system_config_form', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + ); $items['form-test/validate-required'] = array( 'title' => 'Form #required validation', 'page callback' => 'drupal_get_form', @@ -377,6 +384,13 @@ function form_test_object_builder() { } /** + * Page callback: Displays a form built from SystemConfigForm. + */ +function form_test_system_config_form() { + return drupal_get_form(new SystemConfigFormTestForm()); +} + +/** * Form submit handler to return form values as JSON. */ function _form_test_submit_values_json($form, &$form_state) { diff --git a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/SystemConfigFormTestForm.php b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/SystemConfigFormTestForm.php new file mode 100644 index 0000000..d95b42e --- /dev/null +++ b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/SystemConfigFormTestForm.php @@ -0,0 +1,24 @@ +