Been hunting for documentation this for some time - no luck.

Basically elements of type #date_popup render beautifully in node create/edit forms, but when I try to write code to make it happen "manually" it doesn't work. I'm probably overlooking something, like including a file. Here's what I'm trying to do:

  $form['start_date'] = array(
    '#type' => 'date_select',
    '#title' => t('Start Date'),
    '#date_format' => 'Y-m-d',
  );
  $dateform = drupal_render_form('whatever', $form);

  print_r($dateform);

So what am I missing? Did I overlook some documentation?

Comments

therealwebguy’s picture

This looks mostly accurate, as drupal_render_form() will render a form array into HTML. Not entirely sure why you are doing a print_r on the returned result, as drupal_render_form() is going to return a string of HTML, not an array of data. Might be your problem?

tmetzger’s picture

Well I'm not using print_r in the real code. Well spotted. :)

Basically it doesn't seem to be picking up the correct elements when it renders. Not sure what I need to load or include to make that happen! Works fine on node create/edit forms where I've added one or more data_popup elements...

Really quite stuck!