diff --git a/core/modules/simpletest/tests/form.test b/core/modules/simpletest/tests/form.test index c67e57a..0edd209 100644 --- a/core/modules/simpletest/tests/form.test +++ b/core/modules/simpletest/tests/form.test @@ -802,6 +802,16 @@ class FormValidationTestCase extends DrupalWebTestCase { $this->drupalPost('form-test/pattern', $edit, 'Submit'); $this->assertNoRaw($textfield_error); $this->assertNoRaw($tel_error); + + // The pattern attribute overrides #pattern and is not validated on the + // server side. + $edit = array( + 'textfield' => '', + 'tel' => '', + 'url' => 'http://www.example.com/', + ); + $this->drupalPost('form-test/pattern', $edit, 'Submit'); + $this->assertNoRaw(t('%name field is not in the right format.', array('%name' => 'Client side validation'))); } } diff --git a/core/modules/simpletest/tests/form_test.module b/core/modules/simpletest/tests/form_test.module index 532325f..0d36149 100644 --- a/core/modules/simpletest/tests/form_test.module +++ b/core/modules/simpletest/tests/form_test.module @@ -533,6 +533,15 @@ function form_test_pattern_form($form, &$form_state) { '#title' => 'Everything except numbers', '#pattern' => '[^\d]*', ); + $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',