This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

callback in form_alter

in drupal 9.2.7 I use a callback to update an entity reference field. The code I placed in version 8.8 works. I don't know if anything has changed in the 9.
Below is the code I use

Google Photo Library to Site

Dear all,

I would like to have all shared albums of a certain google account automatically into a Drupal website.
I was able to establish a connection with 'Google_photos_api' and show all shared albums on site with code below. (I copied code below to a 'Simple page' - and use Full-HTML (source-code)

Visual Studio Code and Intelliphense

How do I get the VSCode Intelliphense extension to work with Drupal 8,9?

Do Have to copy the Drupal core directory inside my project? What about composer? 

Custom form module not working

Hi there, I followed the most recent drupal form api tutorial from the official website.

But for some reason I am getting this error: The website encountered an unexpected error. Please try again later.

I also don't know what the problem is, because I'm not getting any regular php/drupal errors.

Here's my code:

Autowire for ContainerInjectionInterface possible ?

I'd like to apply the same autowire mechanism used for services to classes implementing ContainerInjectionInterface (ex: forms), to reduce boilerplate code.
For example I have currently:

hook_form_user_register_form_alter

The following is not working: (The description and javascript is working)

function bncreports_form_user_register_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
  $form['account']['name']['#description'] = 'Use Email address as your username';
  $form['account']['name']['#attributes'] = ['onblur' => 'this.value=this.value.toLowerCase();'];
  $form['field_district']['#required'] = true;
  dump($form);
}

The field_district filed is not required when it should be. 

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions