public static function FillEntityVariableFields::fieldValueSave in Business Rules 8
Same name and namespace in other branches
- 2.x src/Plugin/BusinessRulesAction/FillEntityVariableFields.php \Drupal\business_rules\Plugin\BusinessRulesAction\FillEntityVariableFields::fieldValueSave()
Add field and value.
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state object.
File
- src/
Plugin/ BusinessRulesAction/ FillEntityVariableFields.php, line 52
Class
- FillEntityVariableFields
- Class FillEntityVariableFields.
Namespace
Drupal\business_rules\Plugin\BusinessRulesActionCode
public static function fieldValueSave(array $form, FormStateInterface $form_state) {
/** @var \Drupal\business_rules\Entity\Action $action */
$field = $form_state
->getValue('entity_field');
$value = $form_state
->getValue('field_value');
$action = $form_state
->get('business_rules_item');
$field_value = is_array($action
->getSettings('fields_values')) ? $action
->getSettings('fields_values') : [];
$field_value[$field] = [
'entity_field' => $field,
'field_value' => $value,
];
$action
->setSetting('fields_values', $field_value);
$action
->save();
\Drupal::request()->query
->remove('destination');
$form_state
->setRedirect('entity.business_rules_action.edit_form', [
'business_rules_action' => $action
->id(),
], [
'fragment' => 'field_value-' . $field,
]);
}