Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Add placeholder in Drupal form api fields

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 669
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: