Using a 'date' field in the FormAPI, is there something I can set to hide the day field from showing?
I think you could accomplish this using the widgets provided by the Date module, specifically the
$form['date'] = array( '#type' => 'date_text', '#title' => 'Date', '#date_format' => 'm/Y', '#default_value' => date('Y-m-d') );
You can use the
#date_format key to set the level of granularity you want for the element date.
Be aware the default value has to be in the
Y-m-d format for some reason (can't dig out the link to the issue on drupal.org at the moment but I'll update the answer if I find it).
Here's a code example, close to the op request that may help other devs. Based on the answer by @Clive
$form['deadline'] = array( '#title' => 'Deadline ', '#type' => 'date_select', '#date_title' => 'Deadline', '#date_format' => 'm/Y', '#date_year_range' => '0:+1', '#default_value' => variable_get('deadline', date('Y-m')), '#description' => t('Deadline description'), );
If you use this instead of the form api date type element, then the value is stored differently. The form api date element is like this:
array( 'year' => 2013, 'month' => 12, 'day' => 31, );
Whereas the date_select form element is stored as a string:
Although for the example above the value is formatted like this:
So you'll need to adjust the areas of your site that use this data.