Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
layout_paragraphs
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
layout_paragraphs
Commits
75ade204
Commit
75ade204
authored
1 year ago
by
Justin Toupin
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Contracts/ComponentFormInterface.php
+13
-0
13 additions, 0 deletions
src/Contracts/ComponentFormInterface.php
src/Form/ComponentFormBase.php
+22
-1
22 additions, 1 deletion
src/Form/ComponentFormBase.php
with
35 additions
and
1 deletion
src/Contracts/ComponentFormInterface.php
+
13
−
0
View file @
75ade204
...
...
@@ -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
);
}
This diff is collapsed.
Click to expand it.
src/Form/ComponentFormBase.php
+
22
−
1
View file @
75ade204
...
...
@@ -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
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment