You are here

public function FlexiformElementCtoolsContent::configureForm in Flexiform 7

Builds the configuration form for the form element.

Overrides FlexiformElement::configureForm

File

includes/element/ctools_content.element.inc, line 53
Contains class for the Custom HTML form element.

Class

FlexiformElementCtoolsContent
@file Contains class for the Custom HTML form element.

Code

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;
}