function styleswitcher_style_form in Style Switcher 6.2
Same name and namespace in other branches
- 7.2 styleswitcher.admin.inc \styleswitcher_style_form()
Page callback: Constructs a form to add/edit a style.
Parameters
array|null $style: (optional) Style to edit. The structure of an array is the same as returned from styleswitcher_style_load().
See also
styleswitcher_style_form_validate()
styleswitcher_style_form_submit()
1 string reference to 'styleswitcher_style_form'
- styleswitcher_menu in ./
styleswitcher.module - Implements hook_menu().
File
- ./
styleswitcher.admin.inc, line 185 - Styleswitcher configuration functionality.
Code
function styleswitcher_style_form(&$form_state, $style = NULL) {
$form['label'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#description' => t('Human-readable name for this style.'),
'#default_value' => $style ? $style['label'] : '',
'#required' => TRUE,
);
if ($style) {
list(, $name_value) = explode('/', $style['name']);
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Machine-readable name'),
'#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'),
'#default_value' => $style ? $name_value : '',
'#field_prefix' => 'custom/',
'#required' => TRUE,
);
if ($style) {
// Show the warning about renaming styles.
$form['name']['#description'] .= '<br />' . t('<strong>WARNING:</strong> if you change style machine name, users who have chosen this style will see the default one instead until they switch again.');
}
$form['old_name'] = array(
'#type' => 'value',
'#value' => $style ? $style['name'] : '',
);
$form['path'] = array(
'#type' => 'textfield',
'#title' => t('Path'),
'#description' => t('The path to the stylesheet file relative to the site root or an external CSS file.'),
'#default_value' => $style ? $style['path'] : '',
'#required' => TRUE,
'#access' => !$style || isset($style['path']),
);
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
$form['buttons']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
// Do not allow to delete the blank style.
'#access' => isset($style['path']),
);
return $form;
}