You are here

Number.php in Webform 8.5

Same filename and directory in other branches
  1. 6.x src/Plugin/WebformElement/Number.php

File

src/Plugin/WebformElement/Number.php
View source
<?php

namespace Drupal\webform\Plugin\WebformElement;


/**
 * Provides a 'number' element.
 *
 * @WebformElement(
 *   id = "number",
 *   api = "https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!Number.php/class/Number",
 *   label = @Translation("Number"),
 *   description = @Translation("Provides a form element for numeric input, with special numeric validation."),
 *   category = @Translation("Advanced elements"),
 * )
 */
class Number extends NumericBase {

  /**
   * {@inheritdoc}
   */
  protected function defineDefaultProperties() {
    return [
      // Number settings.
      'min' => NULL,
      'max' => NULL,
      'step' => NULL,
    ] + parent::defineDefaultProperties() + $this
      ->defineDefaultMultipleProperties();
  }

  /****************************************************************************/

  /**
   * {@inheritdoc}
   */
  public function preview() {
    return parent::preview() + [
      '#min' => 0,
      '#max' => 10,
      '#step' => 1,
    ];
  }

}

Classes

Namesort descending Description
Number Provides a 'number' element.