public function FlowForm::enableAllReferencedReturn in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x src/Form/FlowForm.php \Drupal\cms_content_sync\Form\FlowForm::enableAllReferencedReturn()
- 2.0.x src/Form/FlowForm.php \Drupal\cms_content_sync\Form\FlowForm::enableAllReferencedReturn()
Enable all referenced => return multiple form elements to replace.
Parameters
array $form:
Return value
\Drupal\Core\Ajax\AjaxResponse AJAX commands to execute
File
- src/
Form/ FlowForm.php, line 486
Class
- FlowForm
- Form handler for the Flow add and edit forms.
Namespace
Drupal\cms_content_sync\FormCode
public function enableAllReferencedReturn($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
foreach ($this->ajaxReplaceElements as $keys) {
$type_key = $keys[0];
$entity_bundle_name = $keys[1];
$bundle_id = $type_key . '-' . $entity_bundle_name;
$settings_id = 'sync-entities-' . $bundle_id;
$response
->addCommand(new ReplaceCommand('#' . $settings_id, $form[$type_key][$entity_bundle_name]));
}
if ('fields' === $this->triggeredAction) {
$type_key = $this->triggeringType;
$entity_bundle_name = $this->triggeringBundle;
$bundle_id = $type_key . '-' . $entity_bundle_name;
$settings_id = 'sync-entities-' . $bundle_id;
$field_settings_id = $settings_id . '-fields';
$response
->addCommand(new ReplaceCommand('#' . $field_settings_id, $form[$type_key][$entity_bundle_name]['fields']));
}
return $response;
}