Default value in hook_form_alter?

Created on 17 May 2018, over 6 years ago
Updated 18 February 2023, almost 2 years ago

I am trying to provide a default value in a textfield and I am hoping someone can assist.

Here's what I'm trying to do:

I've written a function that queries First Name, Last Name, etc. from our Active Directory instance and I am wanting to drop those values into default values based on a user entering their employee id.

Using hook_form_alter, I'm trying to do:

$form['elements']['first_name']['#default_value'] = "Willy";

I've tried various alterations of the same thing, but to no avail. Is it possible to set the default value for a webform field in a similar method to what I've described?

Thanks!

πŸ’¬ Support request
Status

Closed: works as designed

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dozer55

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024