class FlexiformElementFlexiform in Flexiform 7
Class to embed one flexiform inside another.
Hierarchy
- class \FlexiformElement implements FlexiformElementInterface
- class \FlexiformElementFlexiform
Expanded class hierarchy of FlexiformElementFlexiform
2 string references to 'FlexiformElementFlexiform'
- flexiform_flexiform_element_info in ./
flexiform.flexiform.inc - Implements hook_flexiform_element_info().
- hook_flexiform_element_info in ./
flexiform.api.php - Define elements for use in flexiforms.
File
- includes/
element/ flexiform.element.inc, line 10 - Contains FlexiformElementFlexiform class.
View source
class FlexiformElementFlexiform extends FlexiformElement {
/**
* The form name of the form.
*/
protected $form;
/**
* Overrides FlexiformElement::__construct().
*/
public function __construct($flexiform, $settings, $element_namespace = '') {
parent::__construct($flexiform, $settings, $element_namespace);
$this->form = $this->element_info['form'];
$this->label = $settings['label'];
$this->weight = $settings['weight'];
}
/**
* Overrires FlexiformElement::label().
*/
public function label() {
return $this->settings['label'];
}
/**
* Return the type.
*/
public function type() {
return 'Flexiform';
}
/**
* Get the flexiform object of the embedded form.
*/
public function getFlexiform() {
return flexiform_load($this->form);
}
/**
* Build the configure form for the element.
*/
public function configureForm($form, &$form_state, $flexiform) {
$form = parent::configureForm($form, $form_state, $flexiform);
$link = l(t('Edit @flexiform', array(
'@flexiform' => $this
->label(),
)), 'admin/structure/flexiform/manage/' . $this->form);
$form['description'] = array(
'#weight' => -1,
'#markup' => t('There are no settings for @flexiform as it is a nested form. You can edit the flexiform by clicking on the link below, however these changes will effect the form everywhere it is used.<br />!link', array(
'@flexiform' => $this
->label(),
'!link' => $link,
)),
);
return $form;
}
/**
* Overrides FlexiformElement::form().
*/
public function form($form, &$form_state, $entity) {
$form = parent::form($form, $form_state, $entity);
$sub_form = array(
'#parents' => $form['#parents'] + array(
$this->element_namespace,
),
);
$builder = $this
->getFlexiform()
->getBuilder($entity);
$form[$this->element_namespace]['#flexiform_builder'] = $builder;
$form[$this->element_namespace]['#flexiform_element'] = $this;
$form[$this->element_namespace]['#flexiform'] = $this
->getFlexiform();
$form[$this->element_namespace]['#type'] = 'fieldset';
$form[$this->element_namespace]['#title'] = $this
->label();
$form[$this->element_namespace] += $builder
->form($sub_form, $form_state, $entity);
return $form;
}
/**
* Overrides FlexiformElement::formValidate().
*/
public function formValidate($form, &$form_state, $entity, $language = LANGUAGE_NONE) {
$sub_form = $form[$this->element_namespace];
$sub_form['#flexiform_builder']
->formValidate($sub_form, $form_state);
}
/**
* Overrides FlexiformElement::formSubmit().
*/
public function formSubmit($form, &$form_state, $entity, $language = LANGUAGE_NONE) {
$sub_form = $form[$this->element_namespace];
$sub_form['#flexiform_builder']
->formSubmit($sub_form, $form_state);
}
/**
* Overrides FlexifromElement::toSettingsArray();
*/
public function toSettingsArray() {
$settings = parent::toSettingsArray();
$settings['type'] = 'flexiform';
$settings['form'] = $this->form;
$settings['label'] = $this
->label();
return $settings;
}
}
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 | Submit the configure form for the element. | 10 |
FlexiformElement:: |
public | function | Validate the configure form for the element. | 3 |
FlexiformElement:: |
public static | function | Create an element object. | |
FlexiformElement:: |
public | function | Extract the submitted values for this form element. | 12 |
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 | 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 |
FlexiformElementFlexiform:: |
protected | property | The form name of the form. | |
FlexiformElementFlexiform:: |
public | function |
Build the configure form for the element. Overrides FlexiformElement:: |
|
FlexiformElementFlexiform:: |
public | function |
Overrides FlexiformElement::form(). Overrides FlexiformElement:: |
|
FlexiformElementFlexiform:: |
public | function |
Overrides FlexiformElement::formSubmit(). Overrides FlexiformElement:: |
|
FlexiformElementFlexiform:: |
public | function |
Overrides FlexiformElement::formValidate(). Overrides FlexiformElement:: |
|
FlexiformElementFlexiform:: |
public | function | Get the flexiform object of the embedded form. | |
FlexiformElementFlexiform:: |
public | function |
Overrires FlexiformElement::label(). Overrides FlexiformElement:: |
|
FlexiformElementFlexiform:: |
public | function |
Overrides FlexifromElement::toSettingsArray(); Overrides FlexiformElement:: |
|
FlexiformElementFlexiform:: |
public | function |
Return the type. Overrides FlexiformElement:: |
|
FlexiformElementFlexiform:: |
public | function |
Overrides FlexiformElement::__construct(). Overrides FlexiformElement:: |