public static function FillEntityVariableFields::removeFieldValue in Business Rules 8
Same name and namespace in other branches
- 2.x src/Plugin/BusinessRulesAction/FillEntityVariableFields.php \Drupal\business_rules\Plugin\BusinessRulesAction\FillEntityVariableFields::removeFieldValue()
Remove one field/value's setting.
Parameters
string $action: The action id.
string $field: The field id.
string $method: The method ajax|nojs.
Return value
\Drupal\Core\Ajax\AjaxResponse|\Symfony\Component\HttpFoundation\RedirectResponse The AjaxResponse or RedirectResponse object.
1 string reference to 'FillEntityVariableFields::removeFieldValue'
File
- src/
Plugin/ BusinessRulesAction/ FillEntityVariableFields.php, line 100
Class
- FillEntityVariableFields
- Class FillEntityVariableFields.
Namespace
Drupal\business_rules\Plugin\BusinessRulesActionCode
public static function removeFieldValue($action, $field, $method) {
$action = Action::load($action);
$fields_values = $action
->getSettings('fields_values');
unset($fields_values[$field]);
$action
->setSetting('fields_values', $fields_values);
$action
->save();
if ($method == 'ajax') {
$response = new AjaxResponse();
$response
->addCommand(new RemoveCommand('#field_value-' . $field));
return $response;
}
else {
$url = new Url('entity.business_rules_action.edit_form', [
'business_rules_action' => $action
->id(),
]);
return new RedirectResponse($url
->toString());
}
}