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

Jordan_fr created an issue. See original summary.

Version: 8.4.4 » 8.4.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.4.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
cilefen’s picture

Status: Active » Closed (outdated)

I 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.