xref: /dokuwiki/inc/Form/ValueElement.php (revision 0906a39b03a27c4cddc061822a38f0ab60414bdf)
164744a10SAndreas Gohr<?php
264744a10SAndreas Gohr
364744a10SAndreas Gohrnamespace dokuwiki\Form;
464744a10SAndreas Gohr
564744a10SAndreas Gohr/**
664744a10SAndreas Gohr * Class ValueElement
764744a10SAndreas Gohr *
864744a10SAndreas Gohr * Just like an Element but it's value is not part of its attributes
964744a10SAndreas Gohr *
1064744a10SAndreas Gohr * What the value is (tag name, content, etc) is defined by the actual implementations
1164744a10SAndreas Gohr *
1264744a10SAndreas Gohr * @package dokuwiki\Form
1364744a10SAndreas Gohr */
1464744a10SAndreas Gohrabstract class ValueElement extends Element {
1564744a10SAndreas Gohr
1664744a10SAndreas Gohr    /**
1764744a10SAndreas Gohr     * @var string holds the element's value
1864744a10SAndreas Gohr     */
1964744a10SAndreas Gohr    protected $value = '';
2064744a10SAndreas Gohr
2164744a10SAndreas Gohr    /**
2264744a10SAndreas Gohr     * @param string $type
23*0906a39bSGerrit Uitslag     * @param string $value
2464744a10SAndreas Gohr     * @param array $attributes
2564744a10SAndreas Gohr     */
2664744a10SAndreas Gohr    public function __construct($type, $value, $attributes = array()) {
2764744a10SAndreas Gohr        parent::__construct($type, $attributes);
2864744a10SAndreas Gohr        $this->val($value);
2964744a10SAndreas Gohr    }
3064744a10SAndreas Gohr
3164744a10SAndreas Gohr    /**
3264744a10SAndreas Gohr     * Get or set the element's value
3364744a10SAndreas Gohr     *
3464744a10SAndreas Gohr     * @param null|string $value
3564744a10SAndreas Gohr     * @return string|$this
3664744a10SAndreas Gohr     */
3764744a10SAndreas Gohr    public function val($value = null) {
3864744a10SAndreas Gohr        if($value !== null) {
3964744a10SAndreas Gohr            $this->value = $value;
4064744a10SAndreas Gohr            return $this;
4164744a10SAndreas Gohr        }
4264744a10SAndreas Gohr        return $this->value;
4364744a10SAndreas Gohr    }
4464744a10SAndreas Gohr
4564744a10SAndreas Gohr}
46