Skip to content
Snippets Groups Projects
Commit 7218f544 authored by Bharath Kumar Kondeti's avatar Bharath Kumar Kondeti Committed by Andrii Podanenko
Browse files

Updated the patch changes for 2.0.x branch

parent 37e9d7b0
No related branches found
No related tags found
2 merge requests!99Closes #3359875,!72Updated #18 patch changes for 2.0.x branch
......@@ -69,6 +69,9 @@ field.widget.settings.inline_entity_form_complex:
allow_existing:
type: boolean
label: "Allow existing"
allow_edit:
type: boolean
label: "Allow edit"
match_operator:
type: string
label: "Match operator"
......
......@@ -119,6 +119,7 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
$defaults += [
'allow_new' => TRUE,
'allow_existing' => FALSE,
'allow_edit' => TRUE,
'removed_reference' => self::REMOVED_OPTIONAL,
'match_operator' => 'CONTAINS',
'allow_duplicate' => FALSE,
......@@ -153,6 +154,11 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
'#title' => $this->t('Allow users to add existing @label.', ['@label' => $labels['plural']]),
'#default_value' => $this->getSetting('allow_existing'),
];
$element['allow_edit'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow users to edit existing @label.', ['@label' => $labels['plural']]),
'#default_value' => $this->getSetting('allow_edit'),
];
$element['match_operator'] = [
'#type' => 'select',
'#title' => $this->t('Autocomplete matching'),
......@@ -465,7 +471,7 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
// Make sure entity_access is not checked for unsaved entities.
$entity_id = $entity->id();
if (empty($entity_id) || $entity->access('update')) {
if (empty($entity_id) || ($settings['allow_edit'] && $entity->access('update'))) {
$row['actions']['ief_entity_edit'] = [
'#type' => 'submit',
'#value' => $this->t('Edit'),
......
......@@ -105,8 +105,9 @@ class ComplexWidgetTest extends InlineEntityFormTestBase {
$assert_session->elementExists('xpath', $last_name_field_xpath);
$assert_session->buttonExists('Create node');
// Allow addition of existing nodes.
// Allow addition of existing nodes and disable edition.
$this->updateSetting('allow_existing', TRUE);
$this->updateSetting('allow_edit', FALSE);
// Asserts 'Add new node' form elements.
$this->drupalGet($this->formContentAddUrl);
......@@ -355,7 +356,12 @@ class ComplexWidgetTest extends InlineEntityFormTestBase {
$parent_node = $this->drupalGetNodeByTitle('Some title');
// Edit the second entity.
// Unable to edit second entity, feature disabled.
$this->drupalGet('node/' . $parent_node->id() . '/edit');
$assert_session->elementNotExists('xpath', '(//input[@value="Edit"])[2]');
// Edit the second entity once edit is enabled.
$this->updateSetting('allow_edit', TRUE);
$this->drupalGet('node/' . $parent_node->id() . '/edit');
$assert_session->elementExists('xpath', '(//input[@value="Edit"])[2]')->press();
$this->assertNotEmpty($assert_session->waitForElement('xpath', $inner_title_field_xpath));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment