By Alvin Alexander. Last updated: June 4, 2016
Drupal form textfield FAQ: How do I set the default value for a textfield in a Drupal form?
Just use the Drupal form "#default_value" tag, like this:
$form['first_name'] = array( '#title' => t('First Name'), '#type' => 'textfield', '#default_value' => 'John', );
Here's an example of setting the default value of a Drupal textfield to a variable instead of a static text string:
$form['first_name'] = array( '#title' => t('First Name'), '#type' => 'textfield', '#default_value' => $user->first_name, );
As you can see in both of those examples, the key to setting the Drupal form textfield default text is knowing about the Drupal Form API #default_value tag.