mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
BUG Fix <form > tag being invalidly nested inside <p> tag
This commit is contained in:
parent
52072d44eb
commit
09553a1293
@ -342,7 +342,7 @@ class UserDefinedForm_Controller extends Page_Controller {
|
||||
if($this->Content && $form = $this->Form()) {
|
||||
$hasLocation = stristr($this->Content, '$UserDefinedForm');
|
||||
if($hasLocation) {
|
||||
$content = str_ireplace('$UserDefinedForm', $form->forTemplate(), $this->Content);
|
||||
$content = preg_replace('/(<p[^>]*>)?\\$UserDefinedForm(<\\/p>)?/i', $form->forTemplate(), $this->Content);
|
||||
return array(
|
||||
'Content' => DBField::create_field('HTMLText', $content),
|
||||
'Form' => ""
|
||||
|
@ -353,4 +353,20 @@ class UserDefinedFormTest extends FunctionalTest {
|
||||
$result4
|
||||
);
|
||||
}
|
||||
|
||||
public function testIndex() {
|
||||
// Test that the $UserDefinedForm is stripped out
|
||||
$page = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
|
||||
$page->publish('Stage', 'Live');
|
||||
|
||||
$result = $this->get($page->Link());
|
||||
$body = Convert::nl2os($result->getBody(), ''); // strip out newlines
|
||||
$this->assertFalse($result->isError());
|
||||
$this->assertContains('<p>Here is my form</p><form', $body);
|
||||
$this->assertContains('</form><p>Thank you for filling it out</p>', $body);
|
||||
|
||||
$this->assertNotContains('<p>$UserDefinedForm</p>', $body);
|
||||
$this->assertNotContains('<p></p>', $body);
|
||||
$this->assertNotContains('</p><p>Thank you for filling it out</p>', $body);
|
||||
}
|
||||
}
|
@ -204,6 +204,7 @@ UserDefinedForm_EmailRecipient:
|
||||
|
||||
UserDefinedForm:
|
||||
basic-form-page:
|
||||
Content: '<p>Here is my form</p><p>$UserDefinedForm</p><p>Thank you for filling it out</p>'
|
||||
Title: User Defined Form
|
||||
Fields: =>EditableFormStep.form1step1,=>EditableTextField.basic-text
|
||||
EmailRecipients: =>UserDefinedForm_EmailRecipient.recipient-1, =>UserDefinedForm_EmailRecipient.no-html, =>UserDefinedForm_EmailRecipient.no-data
|
||||
|
Loading…
Reference in New Issue
Block a user