Ensure that FormWidgets are correctly initialized with previewMode even on AJAX requests

This commit is contained in:
Luke Towers 2019-01-10 17:39:41 -06:00
parent 1b3263d4c7
commit 5853cc54c4

View File

@ -139,6 +139,11 @@ class FormController extends ControllerBehavior
*/
$this->formWidget = $this->makeWidget('Backend\Widgets\Form', $config);
// Setup the default preview mode on form initialization if the context is preview
if ($config->context === 'preview') {
$this->formWidget->previewMode = true;
}
$this->formWidget->bindEvent('form.extendFieldsBefore', function () {
$this->controller->formExtendFieldsBefore($this->formWidget);
});