function access_scheme_form_handler_element in Access Control Kit 7
Form element builder for enabling and configuring a handler on a scheme form.
Parameters
object $scheme: The access scheme.
string $type: The access-controlled object type.
string $class: The handler class name.
Return value
array The form elements for the handler.
See also
1 call to access_scheme_form_handler_element()
- access_scheme_form in ./
access_schemes.admin.inc - Form constructor for the access scheme add/edit form.
File
- ./
access_schemes.admin.inc, line 307 - Access schemes administrative UI for the access control kit module.
Code
function access_scheme_form_handler_element($scheme, $type, $class) {
// See if this handler is already attached to the scheme.
if (isset($scheme->handlers[$type]) && get_class($scheme->handlers[$type]) == $class) {
$handler = $scheme->handlers[$type];
$chosen = TRUE;
}
else {
$handler = new $class($scheme);
$chosen = FALSE;
}
$info = access_handler_info();
$elements = array(
'#type' => 'container',
);
$elements['handler'] = array(
'#type' => 'radio',
'#title' => check_plain($info[$class]['label']),
'#return_value' => $class,
'#default_value' => $chosen,
'#description' => $handler
->description(),
'#parents' => array(
'handlers',
$type,
'handler',
),
);
$settings = $handler
->settingsForm();
if (!empty($settings)) {
$elements['settings'] = array(
'#parents' => array(
'handlers',
$type,
$class,
),
'#tree' => TRUE,
'#title' => t('Additional settings'),
'#type' => 'fieldset',
'#states' => array(
'visible' => array(
':input[name="handlers[' . $type . '][handler]"]' => array(
'value' => $class,
),
),
),
);
$elements['settings'] += $settings;
}
return $elements;
}