-
Moving a field into a (different) group/fieldset using hook_form_alter()
The following demonstrates how to move a field into a different fieldset within a form using hook_form_alter() and a special #after_build form property.
123456789101112131415161718function mymodule_form_alter(&$form, $form_state, $form_id) {if ($form_id == 'status_node_form' && $form['nid']['#value']) {$form['send_notification'] = array('#type' => 'submit','#value' => t('Send Notification'),'#submit' => array('mymodule_notify_submit'),);$form['#after_build'][] = 'mymodule_notification_afterbuild';}}function mymodule_notification_afterbuild($form, $form_state) {// Add the notifications button to the "Notifications" field group// (defined in the content type field manager)$form['group_notifications']['send_notification'] = $form['send_notification'];unset($form['send_notification']);return $form;} -
Show a timestamp as a date in the Drupal user’s timezone
12345$ts = 1288639479;$local_zone = date_default_timezone_name(TRUE);$newdate = date_make_date($ts, 'UTC', DATE_UNIX);date_timezone_set($newdate, timezone_open($local_zone));print date_format_date($newdate, 'custom', 'm/d/Y H:i');