xref: /dokuwiki/inc/Form/ValueElement.php (revision f6095b17529f34e6ac7d168397a8742e0dcaf0b1)
1<?php
2
3namespace dokuwiki\Form;
4
5/**
6 * Class ValueElement
7 *
8 * Just like an Element but it's value is not part of its attributes
9 *
10 * What the value is (tag name, content, etc) is defined by the actual implementations
11 *
12 * @package dokuwiki\Form
13 */
14abstract class ValueElement extends Element {
15
16    /**
17     * @var string holds the element's value
18     */
19    protected $value = '';
20
21    /**
22     * @param string $type
23     * @param string $value
24     * @param array $attributes
25     */
26    public function __construct($type, $value, $attributes = array()) {
27        parent::__construct($type, $attributes);
28        $this->val($value);
29    }
30
31    /**
32     * Get or set the element's value
33     *
34     * @param null|string $value
35     * @return string|$this
36     */
37    public function val($value = null) {
38        if($value !== null) {
39            $this->value = $value;
40            return $this;
41        }
42        return $this->value;
43    }
44
45}
46