public static function AssociativeArray::arrayElementForm in Map Widget 8
Helper function for building a single key/value pair form.
This method is used in a Form API callback and so needs to be static.
Parameters
string $key: The key.
string $value: The value.
int $size: The field size in characters.
string $keyPlaceholder: The placeholder for the key field.
string $valuePlaceholder: The placeholder for the value field.
bool $required: Is the field required.
Return value
array The render array for the key/value pair.
1 call to AssociativeArray::arrayElementForm()
- AssociativeArray::processAssociativeArray in src/
Element/ AssociativeArray.php - Form API callback: Processes an associative array form element.
File
- src/
Element/ AssociativeArray.php, line 163
Class
- AssociativeArray
- Class KeyValuePair provides a form element for entering paired values.
Namespace
Drupal\map_widget\ElementCode
public static function arrayElementForm($key, $value, $size, $keyPlaceholder, $valuePlaceholder, $required) {
return [
'#type' => 'container',
'#attributes' => [
'class' => [
'map-associative-element',
],
],
'#attached' => [
'library' => [
'map_widget/associative_element',
],
],
'key' => [
'#type' => 'textfield',
'#default_value' => $key,
'#size' => $size,
'#placeholder' => $keyPlaceholder,
'#required' => $required,
'#attributes' => [
'class' => [
'map-associative--key',
],
],
],
'value' => [
'#type' => 'textfield',
'#default_value' => $value,
'#size' => $size,
'#placeholder' => $valuePlaceholder,
'#required' => $required,
'#attributes' => [
'class' => [
'map-associative--value',
],
],
],
];
}