Skip to content

Commit

Permalink
BUG Issues with CMSForm not consistently respecting new form naming s…
Browse files Browse the repository at this point in the history
…cheme.

Fixes for failing CMSFormTest cases
  • Loading branch information
tractorcow committed Oct 30, 2013
1 parent 328a98d commit 4102cc6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
7 changes: 1 addition & 6 deletions admin/code/CMSForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,4 @@ public function getResponseNegotiator() {
return $this->responseNegotiator;
}

public function FormName() {
if($this->htmlID) return $this->htmlID;
else return 'Form_' . str_replace(array('.', '/'), '', $this->name);
}

}
}
10 changes: 5 additions & 5 deletions admin/tests/CMSFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function testValidationExemptActions() {
$response = $this->get('CMSFormTest_Controller');

$response = $this->submitForm(
'Form_Form',
'CMSForm_Form',
'action_doSubmit',
array(
'Email' => 'test@test.com'
Expand All @@ -19,7 +19,7 @@ public function testValidationExemptActions() {

// 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'
),
Expand All @@ -28,20 +28,20 @@ public function testValidationExemptActions() {

// Re-submit the form using validation-exempt button
$response = $this->submitForm(
'Form_Form',
'CMSForm_Form',
'action_doSubmitValidationExempt',
array(
'Email' => 'test@test.com'
)
);

// 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'
),
Expand Down
2 changes: 1 addition & 1 deletion forms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ public function getAttribute($name) {

public function getAttributes() {
$attrs = array(
'id' => $this->getTemplateHelper()->generateFormID($this),
'id' => $this->FormName(),
'action' => $this->FormAction(),
'method' => $this->FormMethod(),
'enctype' => $this->getEncType(),
Expand Down

0 comments on commit 4102cc6

Please sign in to comment.