I want to add a placeholder to my all comment form , here is what i did :
template.php
function ThemeName_form_alter(&$form, &$form_state, $form_id) { if ($form_id == ‘search_block_form’) {
// HTML5 placeholder attribute
$form[‘search_block_form’][‘#attributes’][‘placeholder’] = t(‘Serach …’);
}
switch ($form_id) {
case ‘comment_form’:
$form[‘name’][‘#attributes’][‘placeholder’] = t( ‘Name’ ); $form[‘subject’][‘#attributes’] = array(‘placeholder’ => t(‘Subject’));
$form[‘comment_body’][‘#attributes’] = array(‘placeholder’ => t(‘comment’));
break;
}
}
nothing happend , Any Help ?
Thanks
Update
Finally i could add placeholder to comment form like this
function sizin_form_comment_form_alter(&$form, &$form_state) {
$form[‘author’][‘name’][‘#attributes’][‘placeholder’] = t( ‘Name’ ); $form[‘author’][‘name’][‘#title’]= FALSE;
//Subject
$form[‘your_comment’][‘subject’] = $form[‘subject’];
$form[‘your_comment’][‘subject’][‘#title’] = FALSE;
$form[‘your_comment’][‘subject’][‘#attributes’] = array(‘placeholder’ => t(‘title’));
unset($form[‘subject’]);
$form[‘your_comment’][‘subject’][‘#weight’] = -10;
//Comment
$form[‘your_comment’][‘comment_body’] = $form[‘comment_body’];
$form[‘your_comment’][‘comment_body’][LANGUAGE_NONE][0][‘value’][‘#attributes’] = array(‘placeholder’ => t(‘comment’));
unset($form[‘comment_body’]);
}
But i couldn’t add to textarea(comment Body) ? AnyHelp ?
Link: http://drupaljoomlahosting.com/content/placeholder-comment-form Company: http://texasintegratedservices.com
LinkedIn: https://www.linkedin.com/in/texasintegratedservices