diff --git a/_config/config.yml b/_config/config.yml index 9ab47f4..604a306 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -2,4 +2,4 @@ Name: userformsconfig --- SilverStripe\UserForms\Control\UserDefinedFormController: - disable_form_content_interpolation: false + disable_form_content_shortcode: false diff --git a/code/Control/UserDefinedFormController.php b/code/Control/UserDefinedFormController.php index d381ece..d4001ed 100644 --- a/code/Control/UserDefinedFormController.php +++ b/code/Control/UserDefinedFormController.php @@ -104,14 +104,12 @@ class UserDefinedFormController extends PageController * where the form should be rendered into. If it does not exist * then default back to $Form. * - * @return array|Object + * @return array */ public function index(HTTPRequest $request = null) { - if ($this->config()->disable_form_content_interpolation) { - return $this; - } - if ($this->Content && $form = $this->Form()) { + $form = $this->Form(); + if ($this->Content && $form && !$this->config()->disable_form_content_shortcode) { $hasLocation = stristr($this->Content, '$UserDefinedForm'); if ($hasLocation) { /** @see Requirements_Backend::escapeReplacement */ diff --git a/tests/Control/UserDefinedFormControllerTest.php b/tests/Control/UserDefinedFormControllerTest.php index dc2bfd8..7e8b19c 100644 --- a/tests/Control/UserDefinedFormControllerTest.php +++ b/tests/Control/UserDefinedFormControllerTest.php @@ -280,18 +280,18 @@ class UserDefinedFormControllerTest extends FunctionalTest $form = $this->setupFormFrontend(); $controller = new UserDefinedFormController($form); - $controller->config()->set('disable_form_content_interpolation', true); + $controller->config()->set('disable_form_content_shortcode', true); // check to see if $Form is replaced to inside the content $index = new ArrayData($controller->index()); $html = $index->renderWith(__CLASS__); $parser = new CSSContentParser($html); - // Assert no Content has been rendered - $this->assertNotContains('

Here is my form

$UserDefinedForm

Thank you for filling it out

', $html); - // And no form - $this->assertArrayNotHasKey(0, $parser->getBySelector('form#UserForm_Form_' . $form->ID)); + // Assert Content has been rendered with the shortcode in place + $this->assertContains('

Here is my form

$UserDefinedForm

Thank you for filling it out

', $html); + // And the form in the $From area + $this->assertArrayHasKey(0, $parser->getBySelector('form#UserForm_Form_' . $form->ID)); // check for the input - $this->assertArrayNotHasKey(0, $parser->getBySelector('input.text')); + $this->assertArrayHasKey(0, $parser->getBySelector('input.text')); } /**