Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
image_canvas_editor_api
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
image_canvas_editor_api
Commits
35d97139
Commit
35d97139
authored
6 years ago
by
Eirik Morland
Committed by
Eirik Morland
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3005051
by eiriksm: Bundle can be wrong if using standard image field
parent
1c1b4fad
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/Field/FieldWidget/ImageCanvasEditorWidget.php
+19
-1
19 additions, 1 deletion
src/Plugin/Field/FieldWidget/ImageCanvasEditorWidget.php
with
19 additions
and
1 deletion
src/Plugin/Field/FieldWidget/ImageCanvasEditorWidget.php
+
19
−
1
View file @
35d97139
...
@@ -4,6 +4,7 @@ namespace Drupal\image_canvas_editor_api\Plugin\Field\FieldWidget;
...
@@ -4,6 +4,7 @@ namespace Drupal\image_canvas_editor_api\Plugin\Field\FieldWidget;
use
Drupal\Component\Serialization\Json
;
use
Drupal\Component\Serialization\Json
;
use
Drupal\Component\Utility\NestedArray
;
use
Drupal\Component\Utility\NestedArray
;
use
Drupal\Core\Entity\ContentEntityForm
;
use
Drupal\Core\Field\FieldDefinitionInterface
;
use
Drupal\Core\Field\FieldDefinitionInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Render\ElementInfoManagerInterface
;
use
Drupal\Core\Render\ElementInfoManagerInterface
;
...
@@ -125,11 +126,12 @@ class ImageCanvasEditorWidget extends ImageWidget {
...
@@ -125,11 +126,12 @@ class ImageCanvasEditorWidget extends ImageWidget {
$inline_form
=
NestedArray
::
getValue
(
$form
,
array_slice
(
$element
[
'#array_parents'
],
0
,
4
));
$inline_form
=
NestedArray
::
getValue
(
$form
,
array_slice
(
$element
[
'#array_parents'
],
0
,
4
));
$form_mode
=
$inline_form
[
'#form_mode'
];
$form_mode
=
$inline_form
[
'#form_mode'
];
}
}
$bundle
=
self
::
getBundle
(
$element
,
$form_state
);
$link
=
[
$link
=
[
'#attached'
=>
[
'library'
=>
[
'core/drupal.ajax'
]],
'#attached'
=>
[
'library'
=>
[
'core/drupal.ajax'
]],
'#type'
=>
'link'
,
'#type'
=>
'link'
,
'#url'
=>
Url
::
fromRoute
(
'image_canvas_editor_api.editor'
,
[
'#url'
=>
Url
::
fromRoute
(
'image_canvas_editor_api.editor'
,
[
'bundle'
=>
$
element
[
'#
bundle
'
]
,
'bundle'
=>
$bundle
,
'field_name'
=>
$field_name
,
'field_name'
=>
$field_name
,
'form_mode'
=>
$form_mode
,
'form_mode'
=>
$form_mode
,
'entity_type'
=>
$element
[
'#entity_type'
],
'entity_type'
=>
$element
[
'#entity_type'
],
...
@@ -156,4 +158,20 @@ class ImageCanvasEditorWidget extends ImageWidget {
...
@@ -156,4 +158,20 @@ class ImageCanvasEditorWidget extends ImageWidget {
return
$element
;
return
$element
;
}
}
/**
* Get the bundle from the element, somehow.
*/
public
static
function
getBundle
(
$element
,
FormStateInterface
$form_state
)
{
$bundle
=
NULL
;
if
(
isset
(
$element
[
'#bundle'
]))
{
return
$element
[
'#bundle'
];
}
if
(
$form_object
=
$form_state
->
getFormObject
())
{
if
(
$form_object
instanceof
ContentEntityForm
)
{
return
$form_object
->
getEntity
()
->
bundle
();
}
}
return
$bundle
;
}
}
}
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