function properties_admin_attributes_form in Dynamic properties 7
Form builder; Add/Edit form for attributes.
1 string reference to 'properties_admin_attributes_form'
- properties_menu in ./
properties.module - Implements hook_menu().
File
- ./
properties.admin.inc, line 152 - Contains admin menu callbacks for properties.module.
Code
function properties_admin_attributes_form($form, &$form_state, $attribute = NULL) {
if (empty($attribute)) {
$attribute = (object) array(
'label' => '',
'name' => '',
);
}
$form['label'] = array(
'#title' => t('Attribute label'),
'#type' => 'textfield',
'#default_value' => $attribute->label,
'#maxlength' => 255,
'#required' => TRUE,
);
$form['name'] = array(
'#type' => 'machine_name',
'#default_value' => $attribute->name,
'#maxlength' => 128,
'#disabled' => !empty($attribute->name),
'#machine_name' => array(
'exists' => 'properties_attribute_load',
'source' => array(
'label',
),
'replace' => '_',
),
'#description' => t('A unique machine-readable name for this attribute. It must only contain lowercase letters, numbers, and underscores. This name will be used when using this attribute.'),
);
if (empty($attribute->name)) {
$form['add'] = array(
'#value' => t('Save'),
'#type' => 'submit',
'#submit' => array(
'properties_admin_attributes_add',
),
);
$form['add_another'] = array(
'#value' => t('Save and add another'),
'#type' => 'submit',
'#submit' => array(
'properties_admin_attributes_add_another',
),
);
}
else {
$form['save'] = array(
'#value' => t('Save'),
'#type' => 'submit',
'#submit' => array(
'properties_admin_attributes_save',
),
);
}
return $form;
}