forked from drupal-media/entity_browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request drupal-media#56 from slashrsm/2445853
Inline entity form integration
- Loading branch information
Showing
20 changed files
with
143 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: Entity Browser IEF | ||
description: 'Entity browser inline entity form integration.' | ||
type: module | ||
package: Media | ||
core: 8.x | ||
dependencies: | ||
- entity_browser | ||
- inline_entity_form |
66 changes: 66 additions & 0 deletions
66
modules/entity_form/src/Plugin/EntityBrowser/Widget/EntityForm.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
/** | ||
* Contains \Drupal\entity_browser_entity_form\Plugin\EntityBrowser\Widget\EntityForm. | ||
*/ | ||
|
||
namespace Drupal\entity_browser_entity_form\Plugin\EntityBrowser\Widget; | ||
|
||
use Drupal\Core\Form\FormStateInterface; | ||
use Drupal\entity_browser\WidgetBase; | ||
|
||
/** | ||
* Uses a view to provide entity listing in a browser's widget. | ||
* | ||
* @EntityBrowserWidget( | ||
* id = "entity_form", | ||
* label = @Translation("Entity form"), | ||
* description = @Translation("Provides entity form widget.") | ||
* ) | ||
*/ | ||
class EntityForm extends WidgetBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function defaultConfiguration() { | ||
return array( | ||
'entity_type' => NULL, | ||
'bundle' => NULL, | ||
) + parent::defaultConfiguration(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters) { | ||
if (empty($this->configuration['entity_type']) || empty($this->configuration['entity_type'])) { | ||
return [ | ||
'#markup' => t('Entity type or bundle are no configured correctly.'), | ||
]; | ||
} | ||
|
||
return [ | ||
'inline_entity_form' => [ | ||
'#type' => 'inline_entity_form', | ||
'#op' => 'add', | ||
'#handle_submit' => FALSE, | ||
'#entity_type' => $this->configuration['entity_type'], | ||
'#bundle' => $this->configuration['bundle'], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submit(array &$element, array &$form, FormStateInterface $form_state) { | ||
// We handle submit on our own in order to take control over what's going on. | ||
foreach ($element['inline_entity_form']['#ief_element_submit'] as $function) { | ||
$function($element['inline_entity_form'], $form_state); | ||
} | ||
|
||
$this->selectEntities([$element['inline_entity_form']['#entity']]); | ||
} | ||
|
||
} |
1 change: 0 additions & 1 deletion
1
...play.node.entity_browser_test.default.yml → ...play.node.entity_browser_test.default.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: f5a7f124-2a9c-4527-8b8c-580ba67b04cd | ||
langcode: en | ||
status: true | ||
dependencies: | ||
|
1 change: 0 additions & 1 deletion
1
...play.node.entity_browser_test.default.yml → ...play.node.entity_browser_test.default.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: 5bea4ae9-45f9-4b8d-b210-068e67a4e119 | ||
langcode: en | ||
status: true | ||
dependencies: | ||
|
1 change: 0 additions & 1 deletion
1
...splay.node.entity_browser_test.teaser.yml → ...splay.node.entity_browser_test.teaser.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: 0ca50d8a-2e0a-4985-9bc8-336588886861 | ||
langcode: en | ||
status: true | ||
dependencies: | ||
|
1 change: 0 additions & 1 deletion
1
...all/entity_browser.browser.test_files.yml → ...all/entity_browser.browser.test_files.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: f330ee80-9aa1-457c-b2ca-87fca89f0d08 | ||
langcode: und | ||
status: true | ||
dependencies: { } | ||
|
1 change: 0 additions & 1 deletion
1
...all/entity_browser.browser.test_nodes.yml → ...all/entity_browser.browser.test_nodes.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: a66f548c-51b4-4c79-b436-c27c0c8b1d24 | ||
langcode: und | ||
status: true | ||
dependencies: { } | ||
|
1 change: 0 additions & 1 deletion
1
...d.field.node.entity_browser_test.body.yml → ...d.field.node.entity_browser_test.body.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: 167181a9-2c3e-4993-a278-1c332b8f1706 | ||
langcode: en | ||
status: true | ||
dependencies: | ||
|
1 change: 0 additions & 1 deletion
1
....node.entity_browser_test.field_files.yml → ....node.entity_browser_test.field_files.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: 2862414d-13d6-4eab-8e24-14c29c0a875d | ||
langcode: en | ||
status: true | ||
dependencies: | ||
|
1 change: 0 additions & 1 deletion
1
....node.entity_browser_test.field_nodes.yml → ....node.entity_browser_test.field_nodes.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: dcf59045-164b-4995-ae8d-6b949ec76742 | ||
langcode: en | ||
status: true | ||
dependencies: | ||
|
1 change: 0 additions & 1 deletion
1
...nstall/field.storage.node.field_files.yml → ...nstall/field.storage.node.field_files.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: ce157502-cb91-446f-be29-210dd87c91f7 | ||
langcode: en | ||
status: true | ||
dependencies: | ||
|
1 change: 0 additions & 1 deletion
1
...nstall/field.storage.node.field_nodes.yml → ...nstall/field.storage.node.field_nodes.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: ca628f96-cdcc-4b55-920c-cdeeedea9a2c | ||
langcode: en | ||
status: true | ||
dependencies: | ||
|
1 change: 0 additions & 1 deletion
1
...install/node.type.entity_browser_test.yml → ...install/node.type.entity_browser_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: cd065c6c-9b64-43f2-aa2b-749d48596590 | ||
langcode: en | ||
status: true | ||
dependencies: | ||
|
1 change: 0 additions & 1 deletion
1
...stall/views.view.files_entity_browser.yml → ...stall/views.view.files_entity_browser.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
uuid: 7088ee56-c209-49a3-b24d-bd9088051d06 | ||
langcode: en | ||
status: true | ||
dependencies: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters