I am new to drupal, currently I am creating a new module for forms. Inside of module I have added the code as follows .

$form['first name'] = array(
    '#type' => 'textfield',
    '#title' => t('First Name'),

In this case I wanted to use place holders for text fields. So how can I do ?


1 Answer 1


what do you mean by placeholders? a default value that prefills the textfield or some watermark text that disappears when you focus the textfield? for a default value you can use the #default_value key in the text field definition.

for a watermark i recommend the Placeholder module. the module enables you to use a #placeholder key in your field definition.

cheers j

Not the answer you're looking for? Browse other questions tagged or ask your own question.