function group_role_form in Group 7
Generates the group role editing form.
File
- admin/
group_role.inc, line 23 - Group role editing UI.
Code
function group_role_form($form, &$form_state, GroupRole $group_role, $op = 'edit') {
$locked = entity_has_status('group_role', $group_role, ENTITY_IN_CODE);
if ($op == 'clone') {
$group_role->label .= ' (cloned)';
}
if (empty($group_role->global) && !empty($group_role->type)) {
$form['type'] = array(
'#type' => 'value',
'#value' => $group_role->type,
);
}
$form['label'] = array(
'#title' => t('Label'),
'#type' => 'textfield',
'#default_value' => $group_role->label,
'#description' => t('The human-readable name of this group role.'),
'#required' => TRUE,
'#size' => 30,
);
$form['name'] = array(
'#type' => 'machine_name',
'#default_value' => $group_role->name,
'#maxlength' => 32,
'#disabled' => $locked || $op == 'edit',
'#machine_name' => array(
'exists' => 'group_role_exists',
'source' => array(
'label',
),
'label' => t('Machine name'),
'replace_pattern' => '[^a-z0-9_]+',
'replace' => '_',
),
'#element_validate' => array(
'form_validate_machine_name',
'entity_ui_validate_machine_name',
),
'#description' => t('A unique machine-readable name for this group role. It must only contain lowercase letters, numbers, and underscores.'),
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save group role'),
'#weight' => 40,
);
if (!$locked && $op == 'edit') {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete group role'),
'#weight' => 45,
'#limit_validation_errors' => array(),
'#submit' => array(
'group_role_form_submit_delete',
),
);
}
return $form;
}