function user_expire_field_attach_form in User Expire 7
Implements hook_field_attach_form().
File
- ./
user_expire.module, line 107 - Main module file for User expire module.
Code
function user_expire_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
if ($entity_type == 'user' && user_access('set user expiration')) {
$form['user_expire'] = array(
'#title' => t('User expiration'),
'#type' => 'fieldset',
);
$form['user_expire']['user_expiration'] = array(
'#title' => t('Set expiration for this user'),
'#type' => 'checkbox',
'#default_value' => !empty($entity->expiration),
);
if (isset($entity->expiration)) {
$expiration = array(
'day' => format_date($entity->expiration, 'custom', 'j'),
'month' => format_date($entity->expiration, 'custom', 'n'),
'year' => format_date($entity->expiration, 'custom', 'Y'),
);
}
$form['user_expire']['user_expiration_date'] = array(
'#title' => t('Expiration date'),
'#type' => module_exists('date_popup') ? 'date_popup' : 'date',
'#description' => t('The date on which this account will be disabled.'),
'#date_format' => 'm/d/Y',
'#default_value' => isset($entity->expiration) ? module_exists('date_popup') ? format_date($entity->expiration, 'custom', 'Y-m-d') : $expiration : NULL,
'#required' => isset($form_state['input']['user_expiration']) && $form_state['input']['user_expiration'],
'#states' => array(
'invisible' => array(
':input[name="user_expiration"]' => array(
'checked' => FALSE,
),
),
),
);
}
}