public function AjaxToggleForm::updateFieldValue in Toggle Editable fields 8
Update the clicked field with given value.
Parameters
bool $value: Value given by user.
Throws
\Exception Thrown when the entity can't found the clicked field name.
1 call to AjaxToggleForm::updateFieldValue()
- AjaxToggleForm::formListAjax in src/
Form/ AjaxToggleForm.php  - Update the clicked field with given value.
 
File
- src/
Form/ AjaxToggleForm.php, line 166  
Class
- AjaxToggleForm
 - Build a form to switch state of targeted FieldItem.
 
Namespace
Drupal\toggle_editable_fields\FormCode
public function updateFieldValue($value) {
  if (!$this->entity
    ->hasField($this->fieldName)) {
    throw new \Exception("No field {$this->fieldName} found in {$this->entity->id()} entity.");
  }
  if ($this
    ->fieldIsEditable() || $this
    ->checkEditFieldAccess()) {
    $this->entity
      ->get($this->fieldName)
      ->set($this->delta, $value);
    $this->entity
      ->save();
  }
}