public function ExtraFieldComponentType::buildComponentRow in Flexiform 8
Build a component row for a component of this type.
Parameters
\Drupal\field_ui\Form\EntityDisplayFormBase $form_object: The form object building the configuration form.
string $component_name: The component name.
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
Return value
array An form array representing the row for the given component.
Overrides FormComponentTypeBase::buildComponentRow
1 call to ExtraFieldComponentType::buildComponentRow()
- ExtraFieldComponentType::componentRows in src/
Plugin/ FormComponentType/ ExtraFieldComponentType.php
File
- src/
Plugin/ FormComponentType/ ExtraFieldComponentType.php, line 87
Class
- ExtraFieldComponentType
- Plugin for extra field components.
Namespace
Drupal\flexiform\Plugin\FormComponentTypeCode
public function buildComponentRow(EntityDisplayFormBase $form_object, $component_name, array $form, FormStateInterface $form_state) {
$display_options = $this
->getFormDisplay()
->getComponent($component_name);
$extra_field = $this
->getExtraField($component_name);
$regions = array_keys($form_object
->getRegions());
$extra_field_row = [
'#attributes' => [
'class' => [
'draggable',
'tabledrag-leaf',
],
],
'#row_type' => 'extra_field',
'#region_callback' => [
$form_object,
'getRowRegion',
],
'#js_settings' => [
'rowHandler' => 'field',
],
'human_name' => [
'#markup' => $extra_field['label'],
],
'weight' => [
'#type' => 'textfield',
'#title' => t('Weight for @title', [
'@title' => $extra_field['label'],
]),
'#title_display' => 'invisible',
'#default_value' => $display_options ? $display_options['weight'] : 0,
'#size' => 3,
'#attributes' => [
'class' => [
'field-weight',
],
],
],
'parent_wrapper' => [
'parent' => [
'#type' => 'select',
'#title' => t('Parents for @title', [
'@title' => $extra_field['label'],
]),
'#title_display' => 'invisible',
'#options' => array_combine($regions, $regions),
'#empty_value' => '',
'#attributes' => [
'class' => [
'js-field-parent',
'field-parent',
],
],
'#parents' => [
'fields',
$component_name,
'parent',
],
],
'hidden_name' => [
'#type' => 'hidden',
'#default_value' => $component_name,
'#attributes' => [
'class' => [
'field-name',
],
],
],
],
'region' => [
'#type' => 'select',
'#title' => t('Region for @title', [
'@title' => $extra_field['label'],
]),
'#title_display' => 'invisible',
'#options' => $form_object
->getRegionOptions(),
'#default_value' => $display_options ? $display_options['region'] : 'hidden',
'#attributes' => [
'class' => [
'field-region',
],
],
],
'plugin' => [
'type' => [
'#type' => 'hidden',
'#value' => $display_options ? 'visible' : 'hidden',
'#parents' => [
'fields',
$component_name,
'type',
],
'#attributes' => [
'class' => [
'field-plugin-type',
],
],
],
],
'settings_summary' => [],
'settings_edit' => [],
];
return $extra_field_row;
}