You are here

interface YamlFormElementInterface in YAML Form 8

Defines the interface for form elements.

Hierarchy

Expanded class hierarchy of YamlFormElementInterface

All classes that implement YamlFormElementInterface

See also

\Drupal\yamlform\Annotation\YamlFormElement

\Drupal\yamlform\YamlFormElementBase

\Drupal\yamlform\YamlFormElementManager

\Drupal\yamlform\YamlFormElementManagerInterface

Plugin API

File

src/YamlFormElementInterface.php, line 20

Namespace

Drupal\yamlform
View source
interface YamlFormElementInterface extends PluginInspectionInterface, PluginFormInterface, ContainerFactoryPluginInterface {

  /**
   * Get the URL for the element's API documentation.
   *
   * @return \Drupal\Core\Url|null
   *   The the URL for the element's API documentation.
   */
  public function getPluginApiUrl();

  /**
   * Get link to element's API documentation.
   *
   * @return \Drupal\Core\GeneratedLink|string
   *   A link to element's API documentation.
   */
  public function getPluginApiLink();

  /**
   * Gets the label of the plugin instance.
   *
   * @return string
   *   The label of the plugin instance.
   */
  public function getPluginLabel();

  /**
   * Gets the type name (aka id) of the plugin instance with the 'yamlform_' prefix.
   *
   * @return string
   *   The type name of the plugin instance.
   */
  public function getTypeName();

  /**
   * Get default properties.
   *
   * @return array
   *   An associative array containing default element properties.
   */
  public function getDefaultProperties();

  /**
   * Get translatable properties.
   *
   * @return array
   *   An associative array containing translatable element properties.
   */
  public function getTranslatableProperties();

  /**
   * Determine if an element supports a specified property.
   *
   * @param string $property_name
   *   An element's property name.
   *
   * @return bool
   *   TRUE if the element supports a specified property.
   */
  public function hasProperty($property_name);

  /**
   * Checks if the element carries a value.
   *
   * @param array $element
   *   An element.
   *
   * @return bool
   *   TRUE if the element carries a value.
   */
  public function isInput(array $element);

  /**
   * Checks if the element has a wrapper.
   *
   * @param array $element
   *   An element.
   *
   * @return bool
   *   TRUE if the element has a wrapper.
   */
  public function hasWrapper(array $element);

  /**
   * Checks if element is a container that can contain elements.
   *
   * @param array $element
   *   An element.
   *
   * @return bool
   *   TRUE if the element is a container that can contain elements.
   */
  public function isContainer(array $element);

  /**
   * Checks if element is a root element.
   *
   * @return bool
   *   TRUE if the element is a root element.
   */
  public function isRoot();

  /**
   * Checks if element value could contain multiple lines.
   *
   * @param array $element
   *   An element.
   *
   * @return bool
   *   TRUE if the element value could contain multiple lines.
   */
  public function isMultiline(array $element);

  /**
   * Checks if element is a composite element.
   *
   * @return bool
   *   TRUE if the element is a composite element.
   */
  public function isComposite();

  /**
   * Checks if element is hidden.
   *
   * @return bool
   *   TRUE if the element is hidden.
   */
  public function isHidden();

  /**
   * Checks if element is enabled.
   *
   * @return bool
   *   TRUE if the element is enabled.
   */
  public function isEnabled();

  /**
   * Checks if element is disabled.
   *
   * @return bool
   *   TRUE if the element is disabled.
   */
  public function isDisabled();

  /**
   * Checks if element value has multiple values.
   *
   * @param array $element
   *   An element.
   *
   * @return bool
   *   TRUE if element value has multiple values.
   */
  public function hasMultipleValues(array $element);

  /**
   * Retrieves the default properties for the defined element type.
   *
   * @return array
   *   An associative array describing the element types being defined.
   *
   * @see \Drupal\Core\Render\ElementInfoManagerInterface::getInfo
   */
  public function getInfo();

  /**
   * Get related element types.
   *
   * @param array $element
   *   The element.
   *
   * @return array
   *   An array containing related element types.
   */
  public function getRelatedTypes(array $element);

  /**
   * Gets the actual configuration form array to be built.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @return array
   *   An associative array contain the element's configuration form without
   *   any default values..
   */
  public function form(array $form, FormStateInterface $form_state);

  /**
   * Initialize an element to be displayed, rendered, or exported.
   *
   * @param array $element
   *   An element.
   */
  public function initialize(array &$element);

  /**
   * Prepare an element to be rendered within a form.
   *
   * @param array $element
   *   An element.
   * @param \Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission
   *   A form submission.
   */
  public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission);

  /**
   * Check element access (rules).
   *
   * @param string $operation
   *   The operation access should be checked for.
   *   Usually "create", "update", or "view".
   * @param array $element
   *   An element.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The user session for which to check access.
   *
   * @return bool
   *   TRUE is the element can be accessed by the user.
   *
   * @see \Drupal\yamlform\Entity\YamlForm::checkAccessRules
   * @see \Drupal\yamlform\Entity\YamlForm::checkAccessRule
   */
  public function checkAccessRules($operation, array $element, AccountInterface $account = NULL);

  /**
   * Display element disabled warning.
   *
   * @param array $element
   *   An element.
   */
  public function displayDisabledWarning(array $element);

  /**
   * Set an element's default value using saved data.
   *
   * @param array $element
   *   An element.
   */
  public function setDefaultValue(array &$element);

  /**
   * Get an element's label (#title or #yamlform_key).
   *
   * @param array $element
   *   An element.
   *
   * @return string
   *   An element's label (#title or #yamlform_key).
   */
  public function getLabel(array $element);

  /**
   * Get an element's admin label (#admin_title, #title or #yamlform_key).
   *
   * @param array $element
   *   An element.
   *
   * @return string
   *   An element's label (#admin_title, #title or #yamlform_key).
   */
  public function getAdminLabel(array $element);

  /**
   * Get an element's key/name.
   *
   * @param array $element
   *   An element.
   *
   * @return string
   *   An element's key/name.
   */
  public function getKey(array $element);

  /**
   * Build an element as HTML element.
   *
   * @param array $element
   *   An element.
   * @param array|mixed $value
   *   A value.
   * @param array $options
   *   An array of options.
   *
   * @return array
   *   A render array representing an element as HTML.
   */
  public function buildHtml(array &$element, $value, array $options = []);

  /**
   * Build an element as text element.
   *
   * @param array $element
   *   An element.
   * @param array|mixed $value
   *   A value.
   * @param array $options
   *   An array of options.
   *
   * @return array
   *   A render array representing an element as text.
   */
  public function buildText(array &$element, $value, array $options = []);

  /**
   * Format an element's value as HTML.
   *
   * @param array $element
   *   An element.
   * @param array|mixed $value
   *   A value.
   * @param array $options
   *   An array of options.
   *
   * @return array|string
   *   The element's value formatted as an HTML string or a render array.
   */
  public function formatHtml(array &$element, $value, array $options = []);

  /**
   * Format an element's value as plain text.
   *
   * @param array $element
   *   An element.
   * @param array|mixed $value
   *   A value.
   * @param array $options
   *   An array of options.
   *
   * @return string
   *   The element's value formatted as plain text or a render array.
   */
  public function formatText(array &$element, $value, array $options = []);

  /**
   * Get test value for an element.
   *
   * @param array $element
   *   An element.
   * @param \Drupal\yamlform\YamlFormInterface $yamlform
   *   A form.
   *
   * @return mixed
   *   A test value for an element.
   */
  public function getTestValue(array $element, YamlFormInterface $yamlform);

  /**
   * Get an element's available formats.
   *
   * @return array
   *   An associative array of formats containing name/label pairs.
   */
  public function getFormats();

  /**
   * Get an element's default format name.
   *
   * @return string
   *   An element's default format name.
   */
  public function getDefaultFormat();

  /**
   * Get element's format name by looking for '#format' property, global settings, and finally default settings.
   *
   * @param array $element
   *   An element.
   *
   * @return string
   *   An element's format name.
   */
  public function getFormat(array $element);

  /**
   * Get element's table column(s) settings.
   *
   * @param array $element
   *   An element.
   *
   * @return array
   *   An associative array containing an element's table column(s).
   */
  public function getTableColumn(array $element);

  /**
   * Format an element's table column value.
   *
   * @param array $element
   *   An element.
   * @param array|mixed $value
   *   A value.
   * @param array $options
   *   An array of options returned from ::getTableColumns().
   *
   * @return array|string
   *   The element's value formatted as an HTML string or a render array.
   */
  public function formatTableColumn(array $element, $value, array $options = []);

  /**
   * Get an element's default export options.
   *
   * @return array
   *   An associative array containing an element's default export options.
   */
  public function getExportDefaultOptions();

  /**
   * Get an element's export options form.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   * @param array $export_options
   *   An associative array of default values.
   *
   * @return array
   *   An associative array contain an element's export option form.
   */
  public function buildExportOptionsForm(array &$form, FormStateInterface $form_state, array $export_options);

  /**
   * Get an associative array of element properties from configuration form.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @return array
   *   An associative array of element properties.
   */
  public function getConfigurationFormProperties(array &$form, FormStateInterface $form_state);

  /**
   * Build an element's export header.
   *
   * @param array $element
   *   An element.
   * @param array $options
   *   An associative array of export options.
   *
   * @return array
   *   An array containing the element's export headers.
   *
   * @see \Drupal\yamlform\YamlFormSubmissionExporterInterface::getDefaultExportOptions
   */
  public function buildExportHeader(array $element, array $options);

  /**
   * Build an element's export row.
   *
   * @param array $element
   *   An element.
   * @param array $export_options
   *   An associative array of export options.
   *
   * @return array
   *   An array containing the element's export row.
   *
   * @see \Drupal\yamlform\YamlFormSubmissionExporterInterface::getDefaultExportOptions
   */
  public function buildExportRecord(array $element, $value, array $export_options);

  /**
   * Get an element's supported states as options.
   *
   * @return array
   *   An array of element states.
   */
  public function getElementStateOptions();

  /**
   * Get an element's selectors as options.
   *
   * @param array $element
   *   An element.
   *
   * @return array
   *   An array of element selectors.
   */
  public function getElementSelectorOptions(array $element);

  /**
   * Changes the values of an entity before it is created.
   *
   * @param array $element
   *   An element.
   * @param mixed[] $values
   *   An array of values to set, keyed by property name.
   */
  public function preCreate(array &$element, array $values);

  /**
   * Acts on a form submission element after it is created.
   *
   * @param array $element
   *   An element.
   * @param \Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission
   *   A form submission.
   */
  public function postCreate(array &$element, YamlFormSubmissionInterface $yamlform_submission);

  /**
   * Acts on loaded form submission.
   *
   * @param array $element
   *   An element.
   * @param \Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission
   *   A form submission.
   */
  public function postLoad(array &$element, YamlFormSubmissionInterface $yamlform_submission);

  /**
   * Acts on a form submission element before the presave hook is invoked.
   *
   * @param array $element
   *   An element.
   * @param \Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission
   *   A form submission.
   */
  public function preSave(array &$element, YamlFormSubmissionInterface $yamlform_submission);

  /**
   * Acts on a saved form submission element before the insert or update hook is invoked.
   *
   * @param array $element
   *   An element.
   * @param \Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission
   *   A form submission.
   * @param bool $update
   *   TRUE if the entity has been updated, or FALSE if it has been inserted.
   */
  public function postSave(array &$element, YamlFormSubmissionInterface $yamlform_submission, $update = TRUE);

  /**
   * Delete any additional value associated with an element.
   *
   * Currently only applicable to file uploads.
   *
   * @param array $element
   *   An element.
   * @param \Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission
   *   A form submission.
   */
  public function postDelete(array &$element, YamlFormSubmissionInterface $yamlform_submission);

}

Members

Namesort descending Modifiers Type Description Overrides
ContainerFactoryPluginInterface::create public static function Creates an instance of the plugin. 112
PluginFormInterface::buildConfigurationForm public function Form constructor. 36
PluginFormInterface::submitConfigurationForm public function Form submission handler. 32
PluginFormInterface::validateConfigurationForm public function Form validation handler. 18
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 4
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2
YamlFormElementInterface::buildExportHeader public function Build an element's export header. 1
YamlFormElementInterface::buildExportOptionsForm public function Get an element's export options form. 1
YamlFormElementInterface::buildExportRecord public function Build an element's export row. 1
YamlFormElementInterface::buildHtml public function Build an element as HTML element. 1
YamlFormElementInterface::buildText public function Build an element as text element. 1
YamlFormElementInterface::checkAccessRules public function Check element access (rules). 1
YamlFormElementInterface::displayDisabledWarning public function Display element disabled warning. 1
YamlFormElementInterface::form public function Gets the actual configuration form array to be built. 1
YamlFormElementInterface::formatHtml public function Format an element's value as HTML. 1
YamlFormElementInterface::formatTableColumn public function Format an element's table column value. 1
YamlFormElementInterface::formatText public function Format an element's value as plain text. 1
YamlFormElementInterface::getAdminLabel public function Get an element's admin label (#admin_title, #title or #yamlform_key). 1
YamlFormElementInterface::getConfigurationFormProperties public function Get an associative array of element properties from configuration form. 1
YamlFormElementInterface::getDefaultFormat public function Get an element's default format name. 1
YamlFormElementInterface::getDefaultProperties public function Get default properties. 1
YamlFormElementInterface::getElementSelectorOptions public function Get an element's selectors as options. 1
YamlFormElementInterface::getElementStateOptions public function Get an element's supported states as options. 1
YamlFormElementInterface::getExportDefaultOptions public function Get an element's default export options. 1
YamlFormElementInterface::getFormat public function Get element's format name by looking for '#format' property, global settings, and finally default settings. 1
YamlFormElementInterface::getFormats public function Get an element's available formats. 1
YamlFormElementInterface::getInfo public function Retrieves the default properties for the defined element type. 1
YamlFormElementInterface::getKey public function Get an element's key/name. 1
YamlFormElementInterface::getLabel public function Get an element's label (#title or #yamlform_key). 1
YamlFormElementInterface::getPluginApiLink public function Get link to element's API documentation. 1
YamlFormElementInterface::getPluginApiUrl public function Get the URL for the element's API documentation. 1
YamlFormElementInterface::getPluginLabel public function Gets the label of the plugin instance. 1
YamlFormElementInterface::getRelatedTypes public function Get related element types. 1
YamlFormElementInterface::getTableColumn public function Get element's table column(s) settings. 1
YamlFormElementInterface::getTestValue public function Get test value for an element. 1
YamlFormElementInterface::getTranslatableProperties public function Get translatable properties. 1
YamlFormElementInterface::getTypeName public function Gets the type name (aka id) of the plugin instance with the 'yamlform_' prefix. 1
YamlFormElementInterface::hasMultipleValues public function Checks if element value has multiple values. 1
YamlFormElementInterface::hasProperty public function Determine if an element supports a specified property. 1
YamlFormElementInterface::hasWrapper public function Checks if the element has a wrapper. 1
YamlFormElementInterface::initialize public function Initialize an element to be displayed, rendered, or exported. 1
YamlFormElementInterface::isComposite public function Checks if element is a composite element. 1
YamlFormElementInterface::isContainer public function Checks if element is a container that can contain elements. 1
YamlFormElementInterface::isDisabled public function Checks if element is disabled. 1
YamlFormElementInterface::isEnabled public function Checks if element is enabled. 1
YamlFormElementInterface::isHidden public function Checks if element is hidden. 1
YamlFormElementInterface::isInput public function Checks if the element carries a value. 1
YamlFormElementInterface::isMultiline public function Checks if element value could contain multiple lines. 1
YamlFormElementInterface::isRoot public function Checks if element is a root element. 1
YamlFormElementInterface::postCreate public function Acts on a form submission element after it is created. 1
YamlFormElementInterface::postDelete public function Delete any additional value associated with an element. 1
YamlFormElementInterface::postLoad public function Acts on loaded form submission. 1
YamlFormElementInterface::postSave public function Acts on a saved form submission element before the insert or update hook is invoked. 1
YamlFormElementInterface::preCreate public function Changes the values of an entity before it is created. 1
YamlFormElementInterface::prepare public function Prepare an element to be rendered within a form. 1
YamlFormElementInterface::preSave public function Acts on a form submission element before the presave hook is invoked. 1
YamlFormElementInterface::setDefaultValue public function Set an element's default value using saved data. 1