public function FlexiformElementCtoolsContent::form in Flexiform 7
Returns the custom html that is defined in the configure form.
Overrides FlexiformElement::form
File
- includes/
element/ ctools_content.element.inc, line 12 - Contains class for the Custom HTML form element.
Class
- FlexiformElementCtoolsContent
- @file Contains class for the Custom HTML form element.
Code
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;
}