Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inline_entity_form
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
inline_entity_form
Commits
ad920b97
Commit
ad920b97
authored
1 year ago
by
ghost of drupal past
Committed by
Andrii Podanenko
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2637880
by Charlie ChX Negyesi: Ability to reference an entity and auto open its edit form
parent
dcdd91ed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!99
Closes #3359875
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
+15
-1
15 additions, 1 deletion
src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
+2
-0
2 additions, 0 deletions
src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
with
17 additions
and
1 deletion
src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
+
15
−
1
View file @
ad920b97
...
...
@@ -2,6 +2,7 @@
namespace
Drupal\inline_entity_form\Plugin\Field\FieldWidget
;
use
Drupal\Core\Entity\ContentEntityInterface
;
use
Drupal\Core\Entity\EntityDisplayRepositoryInterface
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Core\Entity\EntityTypeBundleInfoInterface
;
...
...
@@ -397,7 +398,7 @@ abstract class InlineEntityFormBase extends WidgetBase implements ContainerFacto
$widget_state
[
'entities'
][
$delta
]
=
[
'entity'
=>
$entity
,
'weight'
=>
$delta
,
'form'
=>
NULL
,
'form'
=>
self
::
entityIsOpenFromQuery
(
$entity
,
$form_state
)
?
'edit'
:
NULL
,
'needs_save'
=>
$entity
->
isNew
(),
];
}
...
...
@@ -405,6 +406,19 @@ abstract class InlineEntityFormBase extends WidgetBase implements ContainerFacto
}
}
public
static
function
entityIsOpenFromQuery
(
ContentEntityInterface
$entity
,
FormStateInterface
$form_state
)
{
$query
=
\Drupal
::
request
()
->
query
;
if
(
$query
->
has
(
'ief_open'
)
&&
!
$form_state
->
has
(
'inline_entity_form_open'
))
{
$form_state
->
set
(
'inline_entity_form_open'
,
$query
->
get
(
'ief_open'
));
}
if
(
$form_state
->
has
(
'inline_entity_form_open'
))
{
$ief_open
=
$form_state
->
get
(
'inline_entity_form_open'
);
$query_value
=
sprintf
(
'%s:%s'
,
$entity
->
getEntityTypeId
(),
$entity
->
id
());
return
in_array
(
$query_value
,
$ief_open
);
}
return
FALSE
;
}
/**
* Gets inline entity form element.
*
...
...
This diff is collapsed.
Click to expand it.
src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
+
2
−
0
View file @
ad920b97
...
...
@@ -368,6 +368,8 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
$entity
=
$value
[
'entity'
];
$element
[
'entities'
][
$key
][
'#label'
]
=
$this
->
inlineFormHandler
->
getEntityLabel
(
$value
[
'entity'
]);
$element
[
'entities'
][
$key
][
'#entity'
]
=
$value
[
'entity'
];
$element
[
'entities'
][
$key
][
'#id'
]
=
sprintf
(
'ief-scrollto--%s-%s'
,
$entity
->
getEntityTypeId
(),
$entity
->
id
());
$element
[
'entities'
][
$key
][
'#needs_save'
]
=
$value
[
'needs_save'
];
// Handle row weights.
...
...
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