Skip to content
Snippets Groups Projects

Issue #3284647: Respect widget collapsed property unless nested field validation fails

3 files
+ 90
0
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -15,7 +15,9 @@ use Drupal\Core\Field\FieldItemListInterface;
@@ -15,7 +15,9 @@ use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element;
 
use Drupal\Core\Render\Element\Details;
use Drupal\inline_entity_form\TranslationHelper;
use Drupal\inline_entity_form\TranslationHelper;
 
use Drupal\inline_entity_form\WidgetHelper;
use Drupal\rat\v1\RenderArray;
use Drupal\rat\v1\RenderArray;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -298,6 +300,14 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
@@ -298,6 +300,14 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
if ($element['#type'] == 'details') {
if ($element['#type'] == 'details') {
// If there's user input, keep the details open. Otherwise, use settings.
// If there's user input, keep the details open. Otherwise, use settings.
$element['#open'] = $form_state->getUserInput() ?: !$this->getSetting('collapsed');
$element['#open'] = $form_state->getUserInput() ?: !$this->getSetting('collapsed');
 
 
// Store the default state widget setting and custom #pre_render callback.
 
$element['#collapsed_setting'] = $this->getSetting('collapsed');
 
$element['#pre_render'] = [
 
[WidgetHelper::class, 'iefDetailsPreRender'],
 
[Details::class, 'preRenderDetails'],
 
[Details::class, 'preRenderGroup'],
 
];
}
}
$this->prepareFormState($form_state, $items, $element['#translating']);
$this->prepareFormState($form_state, $items, $element['#translating']);
Loading