You are here

class FlexiformBuilderEntityForm in Flexiform 7

Flexiform Builder Class for stock entity forms.

Hierarchy

Expanded class hierarchy of FlexiformBuilderEntityForm

2 string references to 'FlexiformBuilderEntityForm'
flexiform_flexiform_builder_info in ./flexiform.flexiform.inc
Implements hook_flexiform_builder_info().
hook_flexiform_builder_info in ./flexiform.api.php
Register builder classes with the Flexiform system.

File

includes/builder/entity_form.builder.inc, line 10
Contains the FlexiformBuilderEntityForm Class

View source
class FlexiformBuilderEntityForm extends FlexiformBuilder {

  /**
   * Attach all fields for this entity to the form.
   */
  public function form($form, &$form_state) {
    $form = parent::form($form, $form_state);
    $form['#tree'] = TRUE;
    field_attach_form($this->base_entity_type, $this->base_entity, $form, $form_state);
    $this
      ->invoke($form, $form_state);
    return $form;
  }

  /**
   * Validate the Fields
   */
  public function formValidate($form, &$form_state) {
    field_attach_form_validate($this->base_entity_type, $this->base_entity, $form, $form_state);
    $this
      ->invoke($form, $form_state, 'validate');
  }

  /**
   * Submit the form.
   */
  public function formSubmit($form, &$form_state) {
    field_attach_submit($this->base_entity_type, $this->base_entity, $form, $form_state);
    $this
      ->invoke($form, $form_state, 'submit');
    entity_save($this->base_entity_type, $this->base_entity);
    if (module_exists('rules')) {
      $base_entity_wrapper = entity_metadata_wrapper($this->flexiform->base_entity, $form['#flexiform_base_entity']);
      $args = array(
        'base_entity' => $base_entity_wrapper,
      );

      // Fire the most specific rules first and track back to the less specific.
      rules_invoke_event_by_args('flexiform_submit_' . $this->flexiform->form, array(
        'base_entity' => $this->base_entity,
      ));
      rules_invoke_event_by_args('flexiform_group_submit_' . $this->flexiform->form_group, $args);
      rules_invoke_event_by_args('flexiform_any_submit', $args);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FlexiformBuilder::$base_entity protected property The base entity.
FlexiformBuilder::$base_entity_type protected property The base entity type.
FlexiformBuilder::$flexiform protected property The flexiform object.
FlexiformBuilder::formSubmitRedirect public function Submit the form and set up the redirect.
FlexiformBuilder::getCtoolsContexts public function Get an array of ctools context for the flexiform.
FlexiformBuilder::getCtoolsSubstitutionsList public function Build a list of possible ctools substitutions.
FlexiformBuilder::getFlexiform public function Get the Flexiform.
FlexiformBuilder::getFormEntity public function Get a form entity. 1
FlexiformBuilder::invoke public function Invoke hooks to alter the build of this form.
FlexiformBuilder::replaceCtoolsSubstitutions public function Replace ctools substitutions with their values.
FlexiformBuilder::supportsComponent public function Support Components. Overrides FlexiformBuilderInterface::supportsComponent 1
FlexiformBuilder::__construct public function Construct the Flexiform Builder.
FlexiformBuilderEntityForm::form public function Attach all fields for this entity to the form. Overrides FlexiformBuilder::form
FlexiformBuilderEntityForm::formSubmit public function Submit the form. Overrides FlexiformBuilder::formSubmit
FlexiformBuilderEntityForm::formValidate public function Validate the Fields Overrides FlexiformBuilder::formValidate