public static function RgElement::processElement in Brazilian IDs 8
Adds form elements to collect the RG field properties.
File
- src/
Element/ RgElement.php, line 84
Class
- RgElement
- Plugin annotation @FormElement("brazilian_ids_rg");
Namespace
Drupal\brazilian_ids\ElementCode
public static function processElement(array &$element, FormStateInterface $form_state, array &$complete_form) {
$element['rg_fields'] = [
'#type' => $element['#number_only'] ? 'container' : 'fieldset',
'#title' => $element['#title'],
'#description' => $element['#description'],
'#tree' => TRUE,
];
$element['rg_fields']['number'] = [
'#type' => 'textfield',
'#title' => $element['#number_only'] ? $element['#title'] : t('Number'),
'#description' => $element['#number_only'] ? $element['#description'] : '',
'#maxlength' => 20,
'#size' => 20,
'#required' => $element['#required'],
'#default_value' => isset($element['#default_value']['number']) ? $element['#default_value']['number'] : '',
];
if (empty($element['#number_only'])) {
$element['rg_fields']['agency'] = [
'#type' => 'textfield',
'#title' => t('Issuing agency'),
'#maxlength' => 60,
'#size' => 20,
'#required' => $element['#required'],
'#default_value' => isset($element['#default_value']['agency']) ? $element['#default_value']['agency'] : '',
];
$element['rg_fields']['state'] = [
'#type' => 'select',
'#title' => t('State'),
'#options' => $element['#state_options'],
'#empty_value' => '',
'#required' => $element['#required'],
'#default_value' => isset($element['#default_value']['state']) ? $element['#default_value']['state'] : '',
];
}
return $element;
}