You are here

public function CpfWidgetBase::formElementId in CPF 8.2

Returns the element ID.

Parameters

array $element: A form element array containing basic properties for the widget.

Return value

string The element ID.

2 calls to CpfWidgetBase::formElementId()
CpfDigitsWidget::formElement in src/Plugin/Field/FieldWidget/CpfDigitsWidget.php
Returns the form for a single field widget.
CpfWithMaskWidget::formElement in src/Plugin/Field/FieldWidget/CpfWithMaskWidget.php
Returns the form for a single field widget.

File

src/Plugin/Field/FieldWidget/CpfWidgetBase.php, line 37
Contains \Drupal\cpf\Plugin\Field\FieldWidget\CpfWidgetBase.

Class

CpfWidgetBase
Base class for 'Field widget' plugin implementations.

Namespace

Drupal\cpf\Plugin\Field\FieldWidget

Code

public function formElementId(array $element) {
  $field_name = $this->fieldDefinition
    ->getName();
  $field_name = strtolower(str_replace('_', '-', $field_name));
  $element_id = 'edit-' . $field_name . '-' . $element['#delta'] . '-value';
  return $element_id;
}