public static function GeofieldLatLon::latlonProcess in Geofield 8
Generates the Geofield Lat Lon form element.
Parameters
array $element: An associative array containing the properties and children of the element. Note that $element must be taken by reference here, so processed child elements are taken over into $form_state.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
array $complete_form: The complete form structure.
Return value
array The processed element.
File
- src/
Element/ GeofieldLatLon.php, line 62
Class
- GeofieldLatLon
- Provides a Geofield Lat Lon form element.
Namespace
Drupal\geofield\ElementCode
public static function latlonProcess(array &$element, FormStateInterface $form_state, array &$complete_form) {
static::elementProcess($element, $form_state, $complete_form);
if (!empty($element['#geolocation']) && $element['#geolocation'] == TRUE) {
$element['#attached']['library'][] = 'geofield/geolocation';
$element['geocode'] = [
'#type' => 'button',
'#value' => t('Find my location'),
'#name' => 'geofield-html5-geocode-button',
];
$element['#attributes']['class'] = [
'auto-geocode',
];
}
return $element;
}