function node_recur_pre_render in Node recur 7.2
Clean up the returned date repeat form
1 string reference to 'node_recur_pre_render'
- _node_recur_node_recur_form in ./
node_recur.pages.inc - Helper function to provide the basics of the form
File
- ./
node_recur.pages.inc, line 311
Code
function node_recur_pre_render($element) {
$field_name = node_recur_get_date_field_name($element['#entity']->type);
// Hide actual date field
$element['node_recur'][$field_name][LANGUAGE_NONE][0]['value']['#prefix'] = '<div style="display:none">';
$element['node_recur'][$field_name][LANGUAGE_NONE][0]['value']['#suffix'] = '</div>';
if (isset($element['node_recur'][$field_name][LANGUAGE_NONE][0]['show_todate'])) {
$element['node_recur'][$field_name][LANGUAGE_NONE][0]['show_todate']['#prefix'] = '<div style="display:none">';
$element['node_recur'][$field_name][LANGUAGE_NONE][0]['show_todate']['#suffix'] = '</div>';
}
if (isset($element['node_recur'][$field_name][LANGUAGE_NONE][0]['value2'])) {
$element['node_recur'][$field_name][LANGUAGE_NONE][0]['value2']['#prefix'] = '<div style="display:none">';
$element['node_recur'][$field_name][LANGUAGE_NONE][0]['value2']['#suffix'] = '</div>';
}
$rrule =& $element['node_recur'][$field_name][LANGUAGE_NONE][0]['rrule'];
// @todo Fix JS issues with adding more values
$rrule['additions']['#access'] = FALSE;
$rrule['show_additions']['#access'] = FALSE;
$rrule['exceptions']['#access'] = FALSE;
$rrule['show_exceptions']['#access'] = FALSE;
// Hide the month selections and update the labels to improve UX
$rrule['monthly']['day_month']['BYMONTHDAY_BYMONTH_child']['BYMONTH']['#access'] = FALSE;
$rrule['monthly']['day_month']['BYMONTHDAY_BYMONTH_child']['BYMONTHDAY']['#field_suffix'] = t('of each month');
$rrule['monthly']['day_month']['BYDAY_BYMONTH_child']['BYMONTH']['#access'] = FALSE;
$rrule['monthly']['day_month']['BYDAY_BYMONTH_child']['BYDAY_DAY']['#title'] = t('of each month');
// Remove the confusing bits & set some defaults
$val = $element['node_recur']['recur_date']['#value'];
$date_obj = new DateObject(is_array($val) ? $val['value'] : $val);
$dow = substr($date_obj
->format('D'), 0, 2);
$rrule['weekly']['BYDAY'][strtoupper($dow)]['#checked'] = TRUE;
$vals = array_combine(range(1, 31), range(1, 31));
$rrule['monthly']['day_month']['BYMONTHDAY_BYMONTH_child']['BYMONTHDAY']['#options'] = $vals;
$rrule['monthly']['day_month']['BYMONTHDAY_BYMONTH_child']['BYMONTHDAY']['#default_value'] = $date_obj
->format('d');
$rrule['monthly']['day_month']['BYDAY_BYMONTH_child']['BYDAY_DAY']['#default_value'] = strtoupper(substr($date_obj
->format('D'), 0, 2));
$rrule['yearly']['day_month']['BYMONTHDAY_BYMONTH_child']['BYMONTHDAY']['#options'] = $vals;
$rrule['yearly']['day_month']['BYMONTHDAY_BYMONTH_child']['BYMONTHDAY']['#default_value'] = $date_obj
->format('d');
return $element;
}