function commerce_option_set_form in Commerce Product Option 7
Same name and namespace in other branches
- 7.2 commerce_option.admin.inc \commerce_option_set_form()
1 string reference to 'commerce_option_set_form'
- commerce_option_set_form_wrapper in ./
commerce_option.module - Form callback wrapper: create or edit a option set.
File
- includes/
commerce_option_set.forms.inc, line 3
Code
function commerce_option_set_form($form, &$form_state, $option_set, $op = 'edit') {
if ($op == 'clone') {
$option_set->name .= ' (cloned)';
$option_set->set_id = '';
}
$form['name'] = array(
'#title' => t('Name'),
'#type' => 'textfield',
'#default_value' => $option_set->name,
'#description' => t('The human-readable name of this option set.'),
'#required' => TRUE,
'#size' => 30,
);
// Machine-readable type name.
$form['set_id'] = array(
'#type' => 'machine_name',
'#default_value' => isset($option_set->set_id) ? $option_set->set_id : '',
'#maxlength' => 32,
'#disabled' => $option_set
->isLocked() && $op != 'clone',
'#machine_name' => array(
'exists' => 'commerce_option_get_sets',
'source' => array(
'name',
),
),
'#description' => t('A unique machine-readable name for this option set. It must only contain lowercase letters, numbers, and underscores.'),
);
$form['description'] = array(
'#type' => 'textarea',
'#default_value' => $option_set->description,
'#title' => t('Description'),
'#description' => t('This description is shown to the admin user to indicate if this option set is useful for the current purpose.'),
);
$form['data']['#tree'] = TRUE;
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save option set'),
'#weight' => 40,
);
if (!$option_set
->isLocked() && $op != 'add') {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete option set'),
'#weight' => 45,
'#limit_validation_errors' => array(),
'#submit' => array(
'commerce_option_set_form_submit_delete',
),
);
}
return $form;
}