Provides a machine name render element.
Provides a form element to enter a machine name, which is validated to ensure that the name is unique and does not contain disallowed characters.
The element may be automatically populated via JavaScript when used in conjunction with a separate "source" form element (typically specifying the human-readable name). As the user types text into the source element, the JavaScript converts all values to lower case, replaces any remaining disallowed characters with a replacement, and populates the associated machine name form element.
Properties:
In most cases, an existing API or menu argument loader function can be re-used. The callback is only invoked if the submitted value differs from the element's #default_value.
Usage example:
$form['id'] = array( '#type' => 'machine_name', '#default_value' => $this->entity->id(), '#disabled' => !$this->entity->isNew(), '#maxlength' => 64, '#description' => $this->t('A unique name for this item. It must only contain lowercase letters, numbers, and underscores.'), '#machine_name' => array( 'exists' => array($this, 'exists'), ), );
@FormElement("machine_name")
\Drupal\Core\Render\Element\Textfield
Name | Modifiers | Type | Description |
---|---|---|---|
DependencySerializationTrait::$_serviceIds | protected | property | An array of service IDs keyed by property name used for serialization. |
DependencySerializationTrait::__sleep | public | function | |
DependencySerializationTrait::__wakeup | public | function | |
FormElement::processAutocomplete | public static | function | Adds autocomplete functionality to elements. |
FormElement::processPattern | public static | function | #process callback for #pattern form element property. |
FormElement::validatePattern | public static | function | #element_validate callback for #pattern form element property. |
MachineName::getInfo | public | function | Returns the element properties for this element. Overrides Textfield::getInfo |
MachineName::processMachineName | public static | function | Processes a machine-readable name form element. |
MachineName::validateMachineName | public static | function | Form element validation handler for machine_name elements. |
MachineName::valueCallback | public static | function | Determines how user input is mapped to an element's #value property. Overrides Textfield::valueCallback |
PluginBase::$configuration | protected | property | Configuration information passed into the plugin. |
PluginBase::$pluginDefinition | protected | property | The plugin implementation definition. |
PluginBase::$pluginId | protected | property | The plugin_id. |
PluginBase::DERIVATIVE_SEPARATOR | constant | A string which is used to separate base plugin IDs from the derivative ID. | |
PluginBase::getBaseId | public | function | Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId |
PluginBase::getDerivativeId | public | function | Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId |
PluginBase::getPluginDefinition | public | function | Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition |
PluginBase::getPluginId | public | function | Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId |
PluginBase::__construct | public | function | Constructs a Drupal\Component\Plugin\PluginBase object. |
RenderElement::preRenderAjaxForm | public static | function | Adds Ajax information about an element to communicate with JavaScript. |
RenderElement::preRenderGroup | public static | function | Adds members of this group as actual elements for rendering. |
RenderElement::processAjaxForm | public static | function | Form element processing handler for the #ajax form property. |
RenderElement::processGroup | public static | function | Arranges elements into groups. |
RenderElement::setAttributes | public static | function | Sets a form element's class attribute. Overrides ElementInterface::setAttributes |
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. |
StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. |
StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. |
StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. |
StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. |
StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. |
Textfield::preRenderTextfield | public static | function | Prepares a #type 'textfield' render element for input.html.twig. |
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!MachineName.php/class/MachineName/8.1.x