mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Fix(shortcode) re-order if block check $UserDefinedForm in $this->Content. Rename config value to be clearer
This commit is contained in:
parent
ed1e9858af
commit
01520c22bd
@ -2,4 +2,4 @@
|
||||
Name: userformsconfig
|
||||
---
|
||||
SilverStripe\UserForms\Control\UserDefinedFormController:
|
||||
disable_form_content_interpolation: false
|
||||
disable_form_content_shortcode: false
|
||||
|
@ -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 */
|
||||
|
@ -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('<p>Here is my form</p><p>$UserDefinedForm</p><p>Thank you for filling it out</p>', $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('<p>Here is my form</p><p>$UserDefinedForm</p><p>Thank you for filling it out</p>', $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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user