You are here

class ExtraFieldComponent in Flexiform 8

Component class for extra fields.

Hierarchy

Expanded class hierarchy of ExtraFieldComponent

File

src/Plugin/FormComponentType/ExtraFieldComponent.php, line 12

Namespace

Drupal\flexiform\Plugin\FormComponentType
View source
class ExtraFieldComponent extends FormComponentBase {

  /**
   * The extra field definition.
   *
   * @var array
   */
  protected $extraField;

  /**
   * Set the extra field definition.
   */
  public function setExtraField(array $extra_field) {
    $this->extraField = $extra_field;
  }

  /**
   * Render the component in the form.
   */
  public function render(array &$form, FormStateInterface $form_state, RendererInterface $renderer) {

    // Do nothing; extra fields are provided by the entity form handler.
  }

  /**
   * {@inheritdoc}
   */
  public function extractFormValues(array $form, FormStateInterface $form_state) {

    // Do nothing; extra fields are handled by the entity form handler.
  }

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, FormStateInterface $form_state) {

    // Do nothing; extra fields do not have settings.
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function settingsSummary() {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function settingsFormSubmit($values, array $form, FormStateInterface $form_state) {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function getAdminLabel() {
    if (count($this
      ->getFormEntityManager()
      ->getFormEntities()) > 1) {
      return $this->extraField['label'] . ' [' . $this
        ->getFormEntityManager()
        ->getFormEntity('')
        ->getFormEntityContextDefinition()
        ->getLabel() . ']';
    }
    return $this->extraField['label'];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ExtraFieldComponent::$extraField protected property The extra field definition.
ExtraFieldComponent::extractFormValues public function Extract the form values. Overrides FormComponentInterface::extractFormValues
ExtraFieldComponent::getAdminLabel public function Get the admin label for the component. Overrides FormComponentBase::getAdminLabel
ExtraFieldComponent::render public function Render the component in the form. Overrides FormComponentInterface::render
ExtraFieldComponent::setExtraField public function Set the extra field definition.
ExtraFieldComponent::settingsForm public function Get the settings form. Overrides FormComponentBase::settingsForm
ExtraFieldComponent::settingsFormSubmit public function Overrides FormComponentBase::settingsFormSubmit
ExtraFieldComponent::settingsSummary public function Get the settings summary. Overrides FormComponentBase::settingsSummary
FormComponentBase::$formDisplay protected property The form display.
FormComponentBase::$formEntityManager protected property The form entity manager.
FormComponentBase::$name protected property The name of this component.
FormComponentBase::$options protected property The options supplied for this component.
FormComponentBase::getEntityNamespace protected function Get the entity namespace from the component name.
FormComponentBase::getFormDisplay public function
FormComponentBase::getFormEntityManager public function
FormComponentBase::setFormDisplay public function
FormComponentBase::setFormEntityManager public function
FormComponentBase::__construct public function 3