glepiza
asked on
using hook_element_info() to add a placeholder to a form label
Hi.
I am trying to add a placeholder to the date field by using hook_element_info_alter(). There are really few examples of how to do this to add a placeholder, but for some reason it is not working. This is what I am doing:
/**
* Implementation of hook_element_info_alter().
*/
function customize_register_form_el ement_info _alter(&$t ype) {
if (isset($type['text'])) {
$type['text']['#process'][ ] = 'customize_register_form_t ext';
}
}
/**
* Function for editing label.
*/
function customize_register_form_pr ocess_text ($element) {
if ($_GET['q'] == 'user/register') {
if ($element['#array_parents' ][0] == 'account') {
$element['user_user_form_g roup_user_ birth']['# attributes ']['placeh older'] = t('00/00/0000');
}
}
return $element;
}
Could you please help me?
Thanks in advance,
Winter
I am trying to add a placeholder to the date field by using hook_element_info_alter().
/**
* Implementation of hook_element_info_alter().
*/
function customize_register_form_el
if (isset($type['text'])) {
$type['text']['#process'][
}
}
/**
* Function for editing label.
*/
function customize_register_form_pr
if ($_GET['q'] == 'user/register') {
if ($element['#array_parents'
$element['user_user_form_g
}
}
return $element;
}
Could you please help me?
Thanks in advance,
Winter
ASKER
thanks Darren,
For some reason I can´t get it to work, it seems I am using the wrong form field…. please take a look at the screenshot I took to show you the source code and see what I am doing wrong. the form field is suppose to be the name attribute right?
Thanks again,
Captura-de-pantalla-2013-12-13-a.png
For some reason I can´t get it to work, it seems I am using the wrong form field…. please take a look at the screenshot I took to show you the source code and see what I am doing wrong. the form field is suppose to be the name attribute right?
Thanks again,
Captura-de-pantalla-2013-12-13-a.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So sorry, I forgot to close this question. Thanks for your answer!
useing this module: https://drupal.org/project/placeholder
Open in new window