public function CpfWidgetBase::formElementId in CPF 8
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/
CpfWidgetBase.php, line 32
Class
- CpfWidgetBase
- Base class for 'Field widget' plugin implementations.
Namespace
Drupal\cpfCode
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;
}