1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace Ppb\Form\Element;
- use Cube\Form\Element;
- class Range extends Element
- {
- const RANGE_FROM = '0';
- const RANGE_TO = '1';
-
- protected $_element = 'range';
-
- public function __construct($name)
- {
- parent::__construct('text', $name);
- $this->setMultiple(true);
- }
-
- public function getValue($key = null)
- {
- $value = parent::getValue();
- if ($key !== null) {
- if (array_key_exists($key, (array)$value)) {
- return $value[$key];
- }
- else {
- return null;
- }
- }
- return $value;
- }
-
- public function render()
- {
- return $this->getPrefix() . ' '
- . '<input type="' . $this->_type . '" '
- . 'name="' . $this->_name . '[' . self::RANGE_FROM . ']' . '" '
- . $this->renderAttributes()
- . 'value="' . $this->getValue(self::RANGE_FROM) . '" '
- . $this->_endTag . ' '
- . $this->getSuffix()
- . ' - '
- . $this->getPrefix() . ' '
- . '<input type="' . $this->_type . '" '
- . 'name="' . $this->_name . '[' . self::RANGE_TO . ']' . '" '
- . $this->renderAttributes()
- . 'value="' . $this->getValue(self::RANGE_TO) . '" '
- . $this->_endTag . ' '
- . $this->getSuffix();
- }
- }
|