Merge pull request #2623 from tractorcow/pulls/3.2-form-naming-fixes

BUG 3.2 Issues with CMSForm not consistently respecting new form naming scheme
This commit is contained in:
Will Rossiter 2013-10-29 22:26:57 -07:00
commit 1a3a716352
3 changed files with 7 additions and 12 deletions

View File

@ -86,9 +86,4 @@ class CMSForm extends Form {
return $this->responseNegotiator; return $this->responseNegotiator;
} }
public function FormName() { }
if($this->htmlID) return $this->htmlID;
else return 'Form_' . str_replace(array('.', '/'), '', $this->name);
}
}

View File

@ -10,7 +10,7 @@ class CMSFormTest extends FunctionalTest {
$response = $this->get('CMSFormTest_Controller'); $response = $this->get('CMSFormTest_Controller');
$response = $this->submitForm( $response = $this->submitForm(
'Form_Form', 'CMSForm_Form',
'action_doSubmit', 'action_doSubmit',
array( array(
'Email' => 'test@test.com' '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 // Firstly, assert that required fields still work when not using an exempt action
$this->assertPartialMatchBySelector( $this->assertPartialMatchBySelector(
'#SomeRequiredField span.required', '#CMSForm_Form_SomeRequiredField_Holder span.required',
array( array(
'"Some Required Field" is required' '"Some Required Field" is required'
), ),
@ -28,7 +28,7 @@ class CMSFormTest extends FunctionalTest {
// Re-submit the form using validation-exempt button // Re-submit the form using validation-exempt button
$response = $this->submitForm( $response = $this->submitForm(
'Form_Form', 'CMSForm_Form',
'action_doSubmitValidationExempt', 'action_doSubmitValidationExempt',
array( array(
'Email' => 'test@test.com' 'Email' => 'test@test.com'
@ -36,12 +36,12 @@ class CMSFormTest extends FunctionalTest {
); );
// The required message should be empty if validation was skipped // 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); $this->assertEmpty($items);
// And the session message should show up is submitted successfully // And the session message should show up is submitted successfully
$this->assertPartialMatchBySelector( $this->assertPartialMatchBySelector(
'#Form_Form_error', '#CMSForm_Form_error',
array( array(
'Validation skipped' 'Validation skipped'
), ),

View File

@ -693,7 +693,7 @@ class Form extends RequestHandler {
public function getAttributes() { public function getAttributes() {
$attrs = array( $attrs = array(
'id' => $this->getTemplateHelper()->generateFormID($this), 'id' => $this->FormName(),
'action' => $this->FormAction(), 'action' => $this->FormAction(),
'method' => $this->FormMethod(), 'method' => $this->FormMethod(),
'enctype' => $this->getEncType(), 'enctype' => $this->getEncType(),