function asset_type_form in Asset 7
Generates the asset type editing form.
File
- includes/
asset.admin.inc, line 10 - Asset admin page callbacks.
Code
function asset_type_form($form, &$form_state, $asset_type, $op = 'edit') {
if ($op == 'clone') {
$asset_type->name .= ' (cloned)';
$asset_type->type .= '_clone';
}
$form['name'] = array(
'#title' => t('Name'),
'#type' => 'textfield',
'#description' => t('The human-readable name of this asset type. This text will be displayed as part of the list on the <em>Add new asset</em> page. It is recommended that this name begin with a capital letter and contain only letters, numbers, and spaces. This name must be unique.'),
'#required' => TRUE,
'#default_value' => $asset_type->name,
);
// Machine-readable type name.
$form['type'] = array(
'#type' => 'machine_name',
'#default_value' => isset($asset_type->type) ? $asset_type->type : '',
'#disabled' => $asset_type
->isLocked(),
'#machine_name' => array(
'exists' => 'assets_get_types',
'source' => array(
'name',
),
),
'#description' => t('A unique machine-readable name for this asset type. It must only contain lowercase letters, numbers, and underscores.'),
);
$form['description'] = array(
'#title' => t('Description'),
'#type' => 'textarea',
'#default_value' => $asset_type->description,
'#description' => t('Describe this asset type. The text will be displayed on the <em>Add new asset</em> page.'),
);
$form['help'] = array(
'#type' => 'textarea',
'#title' => t('Explanation or submission guidelines'),
'#default_value' => $asset_type->help,
'#description' => t('This text will be displayed at the top of the page when creating or editing asset of this type.'),
);
$form['icons'] = array(
'#type' => 'fieldset',
'#title' => t('Icon settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$icons_options = array(
'none' => t('No icon'),
);
$module_icons = _assets_get_icons();
if (!empty($module_icons)) {
$icons_options = $icons_options + $module_icons;
}
$icons_options_keys = array_keys($icons_options);
$form['icons']['icon'] = array(
'#type' => 'radios',
'#default_value' => $asset_type->icon ? $asset_type->icon : reset($icons_options_keys),
'#options' => $icons_options,
'#title' => t('Button icon'),
);
$form['weight'] = array(
'#title' => t('Weight'),
'#type' => 'weight',
'#default_value' => $asset_type->weight,
'#weight' => 50,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save asset type'),
'#weight' => 40,
);
if (!$asset_type
->isLocked() && $op != 'add' && $op != 'clone') {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete asset type'),
'#weight' => 45,
'#limit_validation_errors' => array(),
'#submit' => array(
'asset_type_form_submit_delete',
),
);
}
return $form;
}