Hello,

I'm having trouble making it work with textareas. Trying to add #hint in the contact message form element. I currently have this:

function test_module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'contact_mail_page') {
    $form['message']['#hint'] = 'test';
  }
}

..although it doesn't seem to work.

Any help appreciated.

Thanks!

Comments

mrlava’s picture

I also cannot get this working with a textarea but the textfield works fine.

field_contact_name = textfield
field_charter_company = textarea

function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'charter_listing_node_form':
       if (isset($form['group_company_information']['field_charter_company'][0])) {
         $form['group_company_information']['field_charter_company'][0]['#after_build'][] = 'blah';
       }
       if (isset($form['group_contact_information']['field_contact_name'][0])) {
         $form['group_contact_information']['field_contact_name'][0]['#after_build'][] = 'blah2';
       }
      break;
  }
}

function blah($element) {
  $element['value']['#hint'] = 'TextArea';
   return $element;
}

function blah2($element) {
  $element['value']['#hint'] = 'TextField';
   return $element;
}
quicksketch’s picture

Hint currently does not work with textareas at all. I think I updated the documentation to reflect that it only works on textfields and password fields, but if Hint claims to work on textareas anywhere we need to remove that claim since it does not work on them at all.

dsdeiz’s picture

Hi!

It's on the project page where I found it supports textareas:

Hint provides a simple API for adding JavaScript "hint" text to text fields and textareas.

quicksketch’s picture

Thanks, I had intended original to make it work with textareas, but that proved a bit tricky. Currently only text fields and password fields are supported.

quicksketch’s picture

Status: Active » Closed (fixed)

Marking fixed as a support request. Not sure if we'll ever support textareas.