diff --git a/admin/code/CMSForm.php b/admin/code/CMSForm.php index 39641a95c..69cb370a7 100644 --- a/admin/code/CMSForm.php +++ b/admin/code/CMSForm.php @@ -86,9 +86,4 @@ class CMSForm extends Form { return $this->responseNegotiator; } - public function FormName() { - if($this->htmlID) return $this->htmlID; - else return 'Form_' . str_replace(array('.', '/'), '', $this->name); - } - -} \ No newline at end of file +} diff --git a/admin/tests/CMSFormTest.php b/admin/tests/CMSFormTest.php index 6eb6767f1..1ad33490d 100644 --- a/admin/tests/CMSFormTest.php +++ b/admin/tests/CMSFormTest.php @@ -10,7 +10,7 @@ class CMSFormTest extends FunctionalTest { $response = $this->get('CMSFormTest_Controller'); $response = $this->submitForm( - 'Form_Form', + 'CMSForm_Form', 'action_doSubmit', array( 'Email' => 'test@test.com' @@ -19,7 +19,7 @@ class CMSFormTest extends FunctionalTest { // Firstly, assert that required fields still work when not using an exempt action $this->assertPartialMatchBySelector( - '#SomeRequiredField span.required', + '#CMSForm_Form_SomeRequiredField_Holder span.required', array( '"Some Required Field" is required' ), @@ -28,7 +28,7 @@ class CMSFormTest extends FunctionalTest { // Re-submit the form using validation-exempt button $response = $this->submitForm( - 'Form_Form', + 'CMSForm_Form', 'action_doSubmitValidationExempt', array( 'Email' => 'test@test.com' @@ -36,12 +36,12 @@ class CMSFormTest extends FunctionalTest { ); // The required message should be empty if validation was skipped - $items = $this->cssParser()->getBySelector('#SomeRequiredField span.required'); + $items = $this->cssParser()->getBySelector('#CMSForm_Form_SomeRequiredField_Holder span.required'); $this->assertEmpty($items); // And the session message should show up is submitted successfully $this->assertPartialMatchBySelector( - '#Form_Form_error', + '#CMSForm_Form_error', array( 'Validation skipped' ), diff --git a/forms/Form.php b/forms/Form.php index 208983e2e..09ff960d3 100644 --- a/forms/Form.php +++ b/forms/Form.php @@ -693,7 +693,7 @@ class Form extends RequestHandler { public function getAttributes() { $attrs = array( - 'id' => $this->getTemplateHelper()->generateFormID($this), + 'id' => $this->FormName(), 'action' => $this->FormAction(), 'method' => $this->FormMethod(), 'enctype' => $this->getEncType(),