Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi everyone
I'm trying to attach a textfield widget on (https://www.drupal.org/project/google_place_autocomplete) on my textfield in my buildForm but no way how to do this. I'm trying to add autocomplete for google place in this field but I can't find a way to set the formatter to the field. Is there a way to get widget on form?
Here is my form :
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['activity_name'] = array(
'#type' => 'textfield',
'#title' => t('Quelle activité?'),
'#required' => true,
);
$form['location_address'] = array(
'#type' => 'textfield',
'#title' => t('Where'),
'#required' => TRUE,
);
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('OK'),
'#button_type' => 'primary',
);
$form['actions']['localiser'] = array(
'#type' => 'button',
'#value' => $this->t('Localiser'),
// '#button_type' => 'primary',
);
return $form;
}
Here is the widget property
/**
* Plugin implementation of the 'field_example_text' widget.
*
* @FieldWidget(
* id = "google_place_autocomplete",
* module = "google_place_autocomplete",
* label = @Translation("Place Autocomplete"),
* field_types = {
* "string"
* }
* )
*/
/**
* Plugin implementation of the 'google_place_map' formatter.
*
* @FieldFormatter(
* id = "google_place_map",
* module = "google_place_autocomplete",
* label = @Translation("Google Map"),
* field_types = {
* "string"
* }
* )
*/
If you have any idea please let me know Thanks you a lot in advance,
Comments
Comment #6
cilefen CreditAttribution: cilefen commentedI am closing this support request because there have been no recent comments.
The Drupal Core issue queue is not the ideal place for support requests. Consider other sources of support.