You are here

public function AjaxToggleForm::setBooststrapDataAttributes in Toggle Editable fields 8

Set booststrap data attributes for given element.

Parameters

array $element: An associative array containing the part of the form structure, representing checkbox element.

1 call to AjaxToggleForm::setBooststrapDataAttributes()
AjaxToggleForm::buildForm in src/Form/AjaxToggleForm.php
Form constructor.

File

src/Form/AjaxToggleForm.php, line 184

Class

AjaxToggleForm
Build a form to switch state of targeted FieldItem.

Namespace

Drupal\toggle_editable_fields\Form

Code

public function setBooststrapDataAttributes(array &$element) {
  foreach ($this->fieldSettings as $data_id => $data_value) {
    if ($data_value != NULL && !isset($element['#attributes']["data-{$data_id}"])) {
      $element['#attributes']["data-{$data_id}"] = $data_value;
    }
  }
}