Hi all,
Sometimes we need to add placeholder in our form fields but it get little bit complex when it comes to form api under Drupal CMS.
There is no hard coded form fields in drupal (In case of content and comment forms), everything is coming dynamically. The best thing to do this is hookformalter, which provide us the way to modify our form before rendering.
For example if we need to add placeholder in comment form then we can do this in our template.php file:
function themename_comment_form($form) {
$form['subject']['#attributes']['placeholder'] = t('Subject');
$form['comment_filter']['comment']['#attributes']['placeholder'] = t('Comment');
return (drupal_render($form));
}
Hope this will help somebody.
0 Comment(s)