Skip to content
Snippets Groups Projects
Commit 75ade204 authored by Justin Toupin's avatar Justin Toupin
Browse files

Make view_mode a property of the component form with a getter and setter

parent 88569f5f
No related branches found
No related tags found
No related merge requests found
......@@ -97,4 +97,17 @@ interface ComponentFormInterface extends FormInterface {
*/
public function successfulAjaxSubmit(array $form, FormStateInterface $form_state);
/**
* Get the form view mode.
*/
public function getFormViewMode();
/**
* Set the form view mode.
*
* @param string $view_mode
* The view mode.
*/
public function setFormViewMode($view_mode);
}
......@@ -83,6 +83,13 @@ abstract class ComponentFormBase extends FormBase implements ComponentFormInterf
*/
protected $entityRepository;
/**
* The form mode to use for rendering the form.
*
* @var string
*/
protected $formMode = 'default';
/**
* {@inheritDoc}
*/
......@@ -157,7 +164,7 @@ abstract class ComponentFormBase extends FormBase implements ComponentFormInterf
FormStateInterface $form_state) {
$this->initFormLangcodes($form_state);
$display = EntityFormDisplay::collectRenderDisplay($this->paragraph, 'default');
$display = EntityFormDisplay::collectRenderDisplay($this->paragraph, $this->getViewMode());
$display->buildForm($this->paragraph, $form, $form_state);
$this->paragraphType = $this->paragraph->getParagraphType();
$lp_config = $this->config('layout_paragraphs.settings');
......@@ -607,4 +614,18 @@ abstract class ComponentFormBase extends FormBase implements ComponentFormInterf
return [];
}
/**
* {@inheritDoc}
*/
public function getViewMode() {
return $this->formMode;
}
/**
* {@inheritDoc}
*/
public function setViewMode($view_mode) {
$this->formMode = $view_mode;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment