Skip to content

Commit

Permalink
Merge pull request drupal-media#56 from slashrsm/2445853
Browse files Browse the repository at this point in the history
Inline entity form integration
  • Loading branch information
slashrsm committed Mar 16, 2015
2 parents 3e2b1a1 + 8e0aa5a commit e62e0fa
Show file tree
Hide file tree
Showing 20 changed files with 143 additions and 55 deletions.
8 changes: 8 additions & 0 deletions modules/entity_form/entity_browser_entity_form.info.yml
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 modules/entity_form/src/Plugin/EntityBrowser/Widget/EntityForm.php
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']]);
}

}
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:
Expand Down
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:
Expand Down
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:
Expand Down
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: { }
Expand Down
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: { }
Expand Down
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:
Expand Down
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:
Expand Down
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:
Expand Down
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:
Expand Down
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:
Expand Down
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:
Expand Down
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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
uuid: a0c47394-1258-4a4c-86e2-1de15681964e
langcode: en
status: true
dependencies:
Expand All @@ -11,7 +10,7 @@ label: 'Nodes entity browser'
module: views
description: ''
tag: ''
base_table: node
base_table: node_field_data
base_field: nid
core: 8.x
display:
Expand All @@ -34,7 +33,7 @@ display:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
Expand Down Expand Up @@ -124,7 +123,7 @@ display:
suffix: ''
target: ''
nl2br: false
max_length: ''
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
Expand Down Expand Up @@ -166,8 +165,9 @@ display:
html: false
hide_empty: false
empty_zero: false
link_to_node: true
plugin_id: node
settings:
link_to_entity: true
plugin_id: field
relationship: none
group_type: group
admin_label: ''
Expand All @@ -182,14 +182,26 @@ display:
element_default_classes: true
empty: ''
hide_alter_empty: true
type:
id: type
table: node
field: type
click_sort_column: value
type: string
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
created:
id: created
table: node_field_data
field: created
relationship: none
group_type: group
admin_label: ''
label: Type
label: 'Created on'
exclude: false
alter:
alter_text: false
Expand All @@ -208,7 +220,7 @@ display:
suffix: ''
target: ''
nl2br: false
max_length: ''
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
Expand All @@ -230,17 +242,20 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
date_format: medium
custom_date_format: ''
timezone: ''
entity_type: node
entity_field: type
plugin_id: standard
entity_field: created
plugin_id: date
status:
id: status
table: node_field_data
field: status
relationship: none
group_type: group
admin_label: ''
label: 'Publishing status'
label: Status
exclude: false
alter:
alter_text: false
Expand All @@ -259,7 +274,7 @@ display:
suffix: ''
target: ''
nl2br: false
max_length: ''
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
Expand All @@ -281,21 +296,33 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
type: yes-no
type_custom_true: ''
type_custom_false: ''
not: '0'
click_sort_column: value
type: boolean
settings:
format: yes-no
format_custom_true: ''
format_custom_false: ''
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: node
entity_field: status
plugin_id: boolean
created:
id: created
plugin_id: field
type:
id: type
table: node_field_data
field: created
field: type
relationship: none
group_type: group
admin_label: ''
label: 'Authored on'
label: Type
exclude: false
alter:
alter_text: false
Expand All @@ -314,7 +341,7 @@ display:
suffix: ''
target: ''
nl2br: false
max_length: ''
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
Expand All @@ -336,12 +363,11 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
date_format: fallback
custom_date_format: ''
timezone: ''
link_to_node: false
machine_name: '0'
entity_type: node
entity_field: created
plugin_id: date
entity_field: type
plugin_id: node_type
filters: { }
sorts:
created:
Expand All @@ -365,17 +391,25 @@ display:
relationships: { }
arguments: { }
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
filter_groups:
operator: AND
groups: { }
cache_metadata:
contexts:
0: node_view_grants
1: user
3: language
cacheable: false
entity_browser_1:
display_plugin: entity_browser
id: entity_browser_1
display_title: 'Entity browser'
position: 1
display_options:
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
cache_metadata:
contexts:
0: node_view_grants
1: user
3: language
cacheable: false
5 changes: 0 additions & 5 deletions src/Plugin/EntityBrowser/Widget/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@

namespace Drupal\entity_browser\Plugin\EntityBrowser\Widget;

use Drupal\Component\Plugin\PluginBase;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\entity_browser\EntityBrowserWidgetInterface;
use Drupal\entity_browser\WidgetBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
* Uses a view to provide entity listing in a browser's widget.
Expand Down
1 change: 0 additions & 1 deletion src/Plugin/EntityBrowser/WidgetSelector/DropDown.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace Drupal\entity_browser\Plugin\EntityBrowser\WidgetSelector;

use Drupal\entity_browser\WidgetsCollection;
use Drupal\entity_browser\WidgetSelectorBase;
use Drupal\Core\Form\FormStateInterface;

Expand Down
1 change: 0 additions & 1 deletion src/Plugin/EntityBrowser/WidgetSelector/Single.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace Drupal\entity_browser\Plugin\EntityBrowser\WidgetSelector;

use Drupal\entity_browser\WidgetsCollection;
use Drupal\entity_browser\WidgetSelectorBase;
use Drupal\Core\Form\FormStateInterface;

Expand Down
1 change: 0 additions & 1 deletion src/Plugin/EntityBrowser/WidgetSelector/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace Drupal\entity_browser\Plugin\EntityBrowser\WidgetSelector;

use Drupal\entity_browser\WidgetsCollection;
use Drupal\entity_browser\WidgetSelectorBase;
use Drupal\Core\Form\FormStateInterface;

Expand Down

0 comments on commit e62e0fa

Please sign in to comment.