public static function ParagraphsWidget::autocollapse in Paragraphs 8
Returns a state with all paragraphs closed, if autocollapse is enabled.
Parameters
array $widget_state: The current widget state.
Return value
array The widget state altered by closing all paragraphs.
3 calls to ParagraphsWidget::autocollapse()
- ParagraphsWidget::addMoreSubmit in src/
Plugin/ Field/ FieldWidget/ ParagraphsWidget.php - Submission handler for the "Add another item" button.
- ParagraphsWidget::duplicateSubmit in src/
Plugin/ Field/ FieldWidget/ ParagraphsWidget.php - Creates a duplicate of the paragraph entity.
- ParagraphsWidget::paragraphsItemSubmit in src/
Plugin/ Field/ FieldWidget/ ParagraphsWidget.php
File
- src/
Plugin/ Field/ FieldWidget/ ParagraphsWidget.php, line 2662
Class
- ParagraphsWidget
- Plugin implementation of the 'entity_reference_revisions paragraphs' widget.
Namespace
Drupal\paragraphs\Plugin\Field\FieldWidgetCode
public static function autocollapse(array $widget_state) {
if ($widget_state['real_item_count'] > 0 && $widget_state['autocollapse'] !== 'none') {
foreach ($widget_state['paragraphs'] as $delta => $value) {
if ($widget_state['paragraphs'][$delta]['mode'] === 'edit') {
$widget_state['paragraphs'][$delta]['mode'] = 'closed';
}
}
}
return $widget_state;
}