You are here

TextField.php in YAML Form 8

File

src/Plugin/YamlFormElement/TextField.php
View source
<?php

namespace Drupal\yamlform\Plugin\YamlFormElement;

use Drupal\yamlform\YamlFormSubmissionInterface;

/**
 * Provides a 'textfield' element.
 *
 * @YamlFormElement(
 *   id = "textfield",
 *   api = "https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!Textfield.php/class/Textfield",
 *   label = @Translation("Text field"),
 *   category = @Translation("Basic elements"),
 * )
 */
class TextField extends TextBase {

  /**
   * {@inheritdoc}
   */
  public function getDefaultProperties() {
    return parent::getDefaultProperties() + [
      // Form display.
      'input_mask' => '',
      // Form validation.
      'counter_type' => '',
      'counter_maximum' => '',
      'counter_message' => '',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission) {
    parent::prepare($element, $yamlform_submission);
    $element['#maxlength'] = !isset($element['#maxlength']) ? 255 : $element['#maxlength'];
  }

}

Classes

Namesort descending Description
TextField Provides a 'textfield' element.