public function ContentBuilder::updateFormSortingOptions in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/social_features/social_content_block/src/ContentBuilder.php \Drupal\social_content_block\ContentBuilder::updateFormSortingOptions()
- 10.3.x modules/social_features/social_content_block/src/ContentBuilder.php \Drupal\social_content_block\ContentBuilder::updateFormSortingOptions()
- 10.0.x modules/social_features/social_content_block/src/ContentBuilder.php \Drupal\social_content_block\ContentBuilder::updateFormSortingOptions()
- 10.1.x modules/social_features/social_content_block/src/ContentBuilder.php \Drupal\social_content_block\ContentBuilder::updateFormSortingOptions()
- 10.2.x modules/social_features/social_content_block/src/ContentBuilder.php \Drupal\social_content_block\ContentBuilder::updateFormSortingOptions()
Update the sorting field after a plugin choice change.
File
- modules/
social_features/ social_content_block/ src/ ContentBuilder.php, line 343
Class
- ContentBuilder
- Class ContentBuilder.
Namespace
Drupal\social_content_blockCode
public function updateFormSortingOptions($form, FormStateInterface $form_state) {
$parents = [
'field_sorting',
];
if ($form_state
->has('layout_builder__component')) {
$parents = array_merge([
'settings',
'block_form',
], $parents);
}
// Check that the currently selected value is valid and change it otherwise.
$value_parents = array_merge($parents, [
'0',
'value',
]);
$sort_value = $form_state
->getValue($value_parents);
$options = NestedArray::getValue($form, array_merge($parents, [
'widget',
'#options',
]));
if ($sort_value === NULL || !isset($options[$sort_value])) {
// Unfortunately this has already triggered a validation error.
$form_state
->clearErrors();
$form_state
->setValue($value_parents, key($options));
}
return NestedArray::getValue($form, $parents);
}