function popup_onload_form in Popup On Load 7
Popup add/edit form.
File
- ./
popup_onload.admin.inc, line 11 - Administrative interface callbacks of the Popup On Load module.
Code
function popup_onload_form($form, &$form_state, $popup_onload, $op = 'edit') {
if ($op == 'clone') {
$popup_onload->name .= ' (cloned)';
}
$form['name'] = [
'#title' => t('Name'),
'#type' => 'textfield',
'#default_value' => $popup_onload->name,
'#description' => t('The human-readable name of the popup.'),
'#required' => TRUE,
];
$form['body'] = [
'#title' => t('Popup content'),
'#type' => 'text_format',
'#default_value' => $popup_onload->body,
'#description' => t('The content of the popup.'),
'#required' => TRUE,
'#format' => !empty($popup_onload->format) ? $popup_onload->format : filter_default_format(),
];
$form['width'] = [
'#title' => t('Width'),
'#type' => 'textfield',
'#default_value' => $popup_onload->width,
'#description' => t('The width of the popup, given in pixels. "0" defaults to auto-detection.'),
'#required' => TRUE,
];
$form['height'] = [
'#title' => t('Height'),
'#type' => 'textfield',
'#default_value' => $popup_onload->height,
'#description' => t('The height of the popup, given in pixels. "0" defaults to auto-detection.'),
'#required' => TRUE,
];
$form['fixed_position'] = [
'#title' => t('Fixed position'),
'#type' => 'checkbox',
'#default_value' => $popup_onload->fixed_position,
'#description' => t('Whether the popup is fixed in the browser window.'),
];
$form['active_popup'] = [
'#title' => t('Active'),
'#type' => 'checkbox',
'#default_value' => $popup_onload->active_popup,
'#description' => t('Activate or deactivate a popup.'),
];
$form['cookie_lifetime_single_checkbox'] = [
'#title' => t('Specify popup cookie lifetime'),
'#type' => 'checkbox',
'#default_value' => !empty($popup_onload->cookie_lifetime_single),
];
$form['cookie_lifetime_single'] = [
'#title' => t('Popup cookie lifetime'),
'#type' => 'textfield',
'#states' => [
'visible' => [
'input[name="cookie_lifetime_single_checkbox"]' => [
'checked' => TRUE,
],
],
],
'#description' => t('Override this only if your server configuration filters out cookies with certain pattern.'),
'#default_value' => isset($popup_onload->cookie_lifetime_single) ? $popup_onload->cookie_lifetime_single : '',
];
$form_state['popup_onload'] = $popup_onload;
field_attach_form('popup_onload', $popup_onload, $form, $form_state);
$submit = [];
if (!empty($form['#submit'])) {
$submit += $form['#submit'];
}
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Save'),
'#weight' => 40,
];
return $form;
}