class FlexiformElementUserRoles in Flexiform 7
Class to add the node title field to a form.
Hierarchy
- class \FlexiformElement implements FlexiformElementInterface
- class \FlexiformElementUserRoles
Expanded class hierarchy of FlexiformElementUserRoles
1 string reference to 'FlexiformElementUserRoles'
- flexiform_flexiform_element_info in ./
flexiform.flexiform.inc - Implements hook_flexiform_element_info().
File
- includes/
element/ user_roles.element.inc, line 10 - Contains class for the User roles element.
View source
class FlexiformElementUserRoles extends FlexiformElement {
/**
* Return the form element for this FlexiformElement.
*/
public function form($form, &$form_state, $entity, $language = LANGUAGE_NONE) {
$parents = $form['#parents'];
$parents[] = 'roles';
// Work out the default value.
$default = '';
if (!empty($this->settings['default_value']['default_value'])) {
$default = $this->settings['default_value']['default_value'];
}
if (!empty($this->settings['default_value']['use_tokens'])) {
$default = $this
->replaceCtoolsSubstitutions($default, $form['#flexiform_entities']);
}
$roles = array_map('check_plain', user_roles(TRUE));
$form[$this->element_namespace] = array(
'#type' => 'checkboxes',
'#parents' => $parents,
'#title' => $this
->label(),
'#required' => FALSE,
'#default_value' => !empty($entity->roles) ? array_keys($entity->roles) : array(),
'#options' => $roles,
);
$form = parent::form($form, $form_state, $entity);
return $form;
}
/**
* Validate the form element.
*/
public function formValidate($form, &$form_state, $entity, $language = LANGUAGE_NONE) {
}
/**
* Submit the form element.
*/
public function formSubmit($form, &$form_state, $entity, $language = LANGUAGE_NONE) {
$roles = $this
->formExtractValues($form, $form_state, $entity);
$entity->roles = $roles;
}
/**
* Extract the submitted values for this form element.
*/
public function formExtractValues($form, &$form_state, $entity) {
$parents = $form['#parents'];
$parents[] = $this
->getEntityNamespace();
$parents[] = 'roles';
$roles = drupal_array_get_nested_value($form_state['values'], $parents);
return $roles;
}
/**
* {@inheritdoc}
*/
public function configureForm($form, &$form_state, $flexiform) {
$form = parent::configureForm($form, $form_state, $flexiform);
return $form;
}
/**
* {@inheritdoc}
*/
public function configureFormSubmit($form, &$form_state, $flexiform) {
parent::configureFormSubmit($form, $form_state, $flexiform);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FlexiformElement:: |
protected | property | The bundle this is on. | |
FlexiformElement:: |
protected | property | The namespace of this element. | |
FlexiformElement:: |
protected | property | The entity namespace of the entity this element is acting on. | |
FlexiformElement:: |
protected | property | The entity type this field is on. | |
FlexiformElement:: |
protected | property | The flexiform entity this element is one. | |
FlexiformElement:: |
protected | property | The settings for this element. | |
FlexiformElement:: |
protected | property | The weight of this element. | |
FlexiformElement:: |
public | function | Validate the configure form for the element. | 3 |
FlexiformElement:: |
public static | function | Create an element object. | |
FlexiformElement:: |
public | function | Work out if the submitted value constitutes empty. | 1 |
FlexiformElement:: |
public | function | Get an array of ctools context for the flexiform. | |
FlexiformElement:: |
public | function | Build a list of possible ctools substitutions. | |
FlexiformElement:: |
public static | function | Get an element object. | |
FlexiformElement:: |
public | function | Get the element namespace for this form element. | |
FlexiformElement:: |
public | function | Get the entity namespace for this form element. | |
FlexiformElement:: |
public | function | Get the entity type for this element. | |
FlexiformElement:: |
public | function | Get the settings. | |
FlexiformElement:: |
public | function | Get the weight of this form element. | |
FlexiformElement:: |
public | function | Get the label for this form element. | 2 |
FlexiformElement:: |
public | function | Make namespace for the element. | 1 |
FlexiformElement:: |
public | function | Get the name for this form element. | |
FlexiformElement:: |
public | function | Build the remove form for the element. | |
FlexiformElement:: |
public | function | Submit the remove form for the element. | |
FlexiformElement:: |
public | function | Validate the remove form for the element. | |
FlexiformElement:: |
public | function | Replace ctools substitutions with their values. | |
FlexiformElement:: |
public | function | Set the label for this form element. | 1 |
FlexiformElement:: |
public | function | Set the weight of this form element. | 1 |
FlexiformElement:: |
public | function | Convert this object into a settings array. | 5 |
FlexiformElement:: |
public | function | Get the type of this form element. | 3 |
FlexiformElement:: |
public | function | Construct the class. | 3 |
FlexiformElementUserRoles:: |
public | function |
Build the configure form for the element. Overrides FlexiformElement:: |
|
FlexiformElementUserRoles:: |
public | function |
Submit the configure form for the element. Overrides FlexiformElement:: |
|
FlexiformElementUserRoles:: |
public | function |
Return the form element for this FlexiformElement. Overrides FlexiformElement:: |
|
FlexiformElementUserRoles:: |
public | function |
Extract the submitted values for this form element. Overrides FlexiformElement:: |
|
FlexiformElementUserRoles:: |
public | function |
Submit the form element. Overrides FlexiformElement:: |
|
FlexiformElementUserRoles:: |
public | function |
Validate the form element. Overrides FlexiformElement:: |