public function AjaxToggleForm::setFieldItem in Toggle Editable fields 8
Initialize this Form Builder with FieldItem definition.
Drupal only supports one form with a given ID per page, so we generate a fieldItem specific ID at getFormId().
Parameters
\Drupal\Core\Field\FieldItemInterface $item: FieldItem to be displayed.
array $settings: The formatter settings.
File
- src/
Form/ AjaxToggleForm.php, line 76
Class
- AjaxToggleForm
- Build a form to switch state of targeted FieldItem.
Namespace
Drupal\toggle_editable_fields\FormCode
public function setFieldItem(FieldItemInterface $item, array $settings = []) {
$this->fieldItem = $item;
$this->fieldDefinition = $item
->getFieldDefinition();
$this->entity = $this->fieldItem
->getEntity();
$this->fieldName = $this->fieldDefinition
->getName();
$this->delta = $this->fieldItem
->getName();
$this->defaultValue = $this->fieldItem->value;
$this->fieldSettings = $settings;
}