I am sure this is something to do with how i am inserting this field; but don't see it.

i am trying to add a simple date picker field to a custom form.

i made a function:

function room_reservations_admin_date_picker($form_state) {
  $form['date'] = array(
    '#type' => 'date_popup',
    '#description' => t('my custom description text'),
    '#title' => 'my custom title',
    '#default_value' => date('Y-m-d'),
    '#date_type' => DATE_DATETIME,
    '#date_timezone' => date_default_timezone(),
    '#date_format' => 'Y-m-d',
    '#date_increment' => 1,
    '#date_year_range' => '-0:+1',
  );
    
  return $form;
}

and then i simply embedded this in to the rest of my html:

$output .= drupal_render(drupal_get_form('room_reservations_admin_date_picker'));

it works fine except that my title and desc do not replace the default ones that show up: http://screencast.com/t/UCIglxwD

do i need to hide these with CSS or is there something i am missing here?

Comments

liquidcms’s picture

i added an after_build function to do this:

function _room_reservations_admin_date_picker_afterbuild($form, &$form_state) {
  $form['date']['date']['#title'] = '';
  $form['date']['date']['#description'] = t('click in box to select date');
  
  return $form;  
}

not sure if this is best method or not.

rutger.gabriel’s picture

Having the same issue here, when changing the Date field's helptext through configuration, the default helptext keeps showing up instead of my custom text. I also used a custom 'after_build' function to change that. It's not the most ideal way but providing the helptext is a big deal in my project.

apaderno’s picture

Title: can't modify label or description on date field » I can't modify label or description on date field