You are here

class FlexiformElementCustomHtml in Flexiform 7

@file Contains class for the Custom HTML form element.

Hierarchy

Expanded class hierarchy of FlexiformElementCustomHtml

1 string reference to 'FlexiformElementCustomHtml'
flexiform_flexiform_element_info in ./flexiform.flexiform.inc
Implements hook_flexiform_element_info().

File

includes/element/custom_html.element.inc, line 7
Contains class for the Custom HTML form element.

View source
class FlexiformElementCustomHtml extends FlexiformRepeatableElement {

  /**
   * Returns the custom html that is defined in the configure form.
   */
  public function form($form, &$form_state, $entity) {
    $parents = $form['#parents'];
    $parents[] = 'custom_html';
    $value = $form['#flexiform']->elements[$this
      ->getElementNamespace()]['custom_html']['value'];
    $format = $form['#flexiform']->elements[$this
      ->getElementNamespace()]['custom_html']['format'];

    // Perform some keyword substitution.
    $value = $this
      ->replaceCtoolsSubstitutions($value, $form['#flexiform_entities']);
    $form[$this->element_namespace] = array(
      '#type' => 'item',
      '#support_flexiform_conditional_fields' => TRUE,
      '#markup' => check_markup($value, $format),
      '#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) {
    $form['custom_html'] = array(
      '#type' => 'text_format',
      '#title' => $this
        ->label(),
      '#format' => !empty($this->settings['custom_html']['format']) ? $this->settings['custom_html']['format'] : NULL,
      '#default_value' => !empty($this->settings['custom_html']['value']) ? $this->settings['custom_html']['value'] : '',
    );
    $form['contexts'] = array(
      '#title' => t('Substitutions'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['contexts']['contexts'] = $this
      ->getCtoolsSubstitutionsList();
    $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['custom_html'] = $form_state['values']['custom_html'];
    parent::configureFormSubmit($form, $form_state, $flexiform);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FlexiformElement::$bundle protected property The bundle this is on.
FlexiformElement::$element_namespace protected property The namespace of this element.
FlexiformElement::$entity_namespace protected property The entity namespace of the entity this element is acting on.
FlexiformElement::$entity_type protected property The entity type this field is on.
FlexiformElement::$flexiform protected property The flexiform entity this element is one.
FlexiformElement::$settings protected property The settings for this element.
FlexiformElement::$weight protected property The weight of this element.
FlexiformElement::createElement public static function Create an element object.
FlexiformElement::formExtractValues public function Extract the submitted values for this form element. 12
FlexiformElement::formIsEmpty public function Work out if the submitted value constitutes empty. 1
FlexiformElement::formSubmit public function Submit the form element. 13
FlexiformElement::formValidate public function Validate the form element. 13
FlexiformElement::getCtoolsContexts public function Get an array of ctools context for the flexiform.
FlexiformElement::getCtoolsSubstitutionsList public function Build a list of possible ctools substitutions.
FlexiformElement::getElement public static function Get an element object.
FlexiformElement::getElementNamespace public function Get the element namespace for this form element.
FlexiformElement::getEntityNamespace public function Get the entity namespace for this form element.
FlexiformElement::getEntityType public function Get the entity type for this element.
FlexiformElement::getSettings public function Get the settings.
FlexiformElement::getWeight public function Get the weight of this form element.
FlexiformElement::label public function Get the label for this form element. 2
FlexiformElement::name public function Get the name for this form element.
FlexiformElement::removeForm public function Build the remove form for the element.
FlexiformElement::removeFormSubmit public function Submit the remove form for the element.
FlexiformElement::removeFormValidate public function Validate the remove form for the element.
FlexiformElement::replaceCtoolsSubstitutions public function Replace ctools substitutions with their values.
FlexiformElement::setLabel public function Set the label for this form element. 1
FlexiformElement::setWeight public function Set the weight of this form element. 1
FlexiformElement::toSettingsArray public function Convert this object into a settings array. 5
FlexiformElement::type public function Get the type of this form element. 3
FlexiformElement::__construct public function Construct the class. 3
FlexiformElementCustomHtml::configureForm public function Builds the configuration form for the form element. Overrides FlexiformElement::configureForm
FlexiformElementCustomHtml::configureFormSubmit public function Submit the form element. Overrides FlexiformElement::configureFormSubmit
FlexiformElementCustomHtml::configureFormValidate public function Validate the form element. Overrides FlexiformElement::configureFormValidate
FlexiformElementCustomHtml::form public function Returns the custom html that is defined in the configure form. Overrides FlexiformElement::form
FlexiformRepeatableElement::makeElementNamespace public function Make a namespace for the element. Overrides FlexiformElement::makeElementNamespace