class FlexiformElementCtoolsContent in Flexiform 7
@file Contains class for the Custom HTML form element.
Hierarchy
- class \FlexiformElement implements FlexiformElementInterface
- class \FlexiformRepeatableElement
Expanded class hierarchy of FlexiformElementCtoolsContent
1 string reference to 'FlexiformElementCtoolsContent'
- flexiform_flexiform_element_info in ./
flexiform.flexiform.inc - Implements hook_flexiform_element_info().
File
- includes/
element/ ctools_content.element.inc, line 7 - Contains class for the Custom HTML form element.
View source
class FlexiformElementCtoolsContent extends FlexiformRepeatableElement {
/**
* Returns the custom html that is defined in the configure form.
*/
public function form($form, &$form_state, $entity) {
ctools_include('content');
$parents = $form['#parents'];
$parents[] = 'ctools_content';
$contexts = $this
->getCtoolsContexts($form['#flexiform_entities']);
$type = $this->element_info['content_type'];
$subtype = $this->element_info['sub_type'];
$conf = !empty($this->settings['conf']) ? $this->settings['conf'] : array();
$plugin_info = ctools_content_get_subtype($type, $subtype);
if (!empty($plugin_info['required context'])) {
if (is_array($plugin_info['required context'])) {
$conf['context'] = array(
$this->entity_namespace,
);
}
else {
$conf['context'] = $this->entity_namespace;
}
}
$content = ctools_content_render($type, $subtype, $conf, array(), array(), $contexts)->content;
if (is_array($content)) {
$content = drupal_render($content);
}
$form[$this->element_namespace] = array(
'#type' => 'item',
'#support_flexiform_conditional_fields' => TRUE,
'#markup' => $content,
'#parents' => $parents,
);
$form = parent::form($form, $form_state, $entity);
return $form;
}
/**
* Builds the configuration form for the form element.
*/
public function configureForm($form, &$form_state, $flexiform) {
ctools_include('content');
$type = $this->element_info['content_type'];
$subtype = $this->element_info['sub_type'];
$conf = !empty($this->settings['conf']) ? $this->settings['conf'] : array();
$plugin_info = ctools_get_content_type($type);
$subtype_info = ctools_content_get_subtype($type, $subtype);
$config_form_callback = $plugin_info['edit form'];
if (!empty($subtype_info['edit form'])) {
$config_form_callback = $subtype_info['edit form'];
}
if (is_array($config_form_callback)) {
$config_form_callback = reset($config_form_callback);
}
$form_state['plugin'] = ctools_get_content_type($type);
$form_state['subtype'] = $plugin_info;
$form_state['conf'] = $conf;
$form_state['subtype_name'] = $subtype;
$form_state['op'] = 'edit';
$form['conf'] = array(
'#type' => 'container',
'#tree' => TRUE,
);
$form['conf'] = $config_form_callback($form['conf'], $form_state);
$form = parent::configureForm($form, $form_state, $flexiform);
return $form;
}
/**
* Validate the form element.
*/
public function configureFormValidate($form, &$form_state, $flexiform) {
parent::configureFormValidate($form, $form_state, $flexiform);
}
/**
* Submit the form element.
*/
public function configureFormSubmit($form, &$form_state, $flexiform) {
$this->settings['conf'] = $form_state['values']['conf'];
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 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 | Submit the form element. | 13 |
FlexiformElement:: |
public | function | Validate the form element. | 13 |
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 | 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 |
FlexiformElementCtoolsContent:: |
public | function |
Builds the configuration form for the form element. Overrides FlexiformElement:: |
|
FlexiformElementCtoolsContent:: |
public | function |
Submit the form element. Overrides FlexiformElement:: |
|
FlexiformElementCtoolsContent:: |
public | function |
Validate the form element. Overrides FlexiformElement:: |
|
FlexiformElementCtoolsContent:: |
public | function |
Returns the custom html that is defined in the configure form. Overrides FlexiformElement:: |
|
FlexiformRepeatableElement:: |
public | function |
Make a namespace for the element. Overrides FlexiformElement:: |