Skip to content
Snippets Groups Projects

Issue #3263496 by mupsi: Fix error adding element to library from default layout form by supporting Display and Entity contexts for default and overridden layouts

Merged Issue #3263496 by mupsi: Fix error adding element to library from default layout form by supporting Display and Entity contexts for default and overridden layouts

Files

@@ -2,6 +2,7 @@
namespace Drupal\section_library\Form;
use Drupal\Component\Plugin\Exception\ContextException;
use Drupal\Core\Ajax\AjaxFormHelperTrait;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
@@ -146,7 +147,19 @@ class AddSectionToLibraryForm extends FormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$current_section = $this->sectionStorage->getSection($this->delta);
$deep_cloned_section = $this->deepCloneSection($current_section);
$layout_entity = $this->sectionStorage->getContextValue('entity');
$layout_entity = NULL;
foreach (['entity', 'display'] as $name) {
try {
$layout_entity = $this->sectionStorage->getContextValue($name);
}
catch (ContextException $e) {
// Let's try again.
}
}
if (!$layout_entity) {
throw new ContextException('', 0, $e);
}
$entity_values = [
'label' => $form_state->getValue('label'),
Loading