diff options
author | Andreas Gohr <andi@splitbrain.org> | 2015-08-18 20:36:08 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2015-08-18 20:38:33 +0200 |
commit | a453c16b3290eabdf35778c54498101c737544e1 (patch) | |
tree | c3638bb285b3005758df58e81e7b148ea373523e /inc/Form/LabelElement.php | |
parent | 8f0df229ed3e82191f118594ea5145c9d5942d7b (diff) | |
download | rpg-a453c16b3290eabdf35778c54498101c737544e1.tar.gz rpg-a453c16b3290eabdf35778c54498101c737544e1.tar.bz2 |
Form: more flexible label handling #1312
You now can add labels that don't wrap around inputs, but you have to
ensure IDs are properly assigned yourself.
The Label class has been renamed to LabelElement to reflect the naming
scheme of the other elements.
Diffstat (limited to 'inc/Form/LabelElement.php')
-rw-r--r-- | inc/Form/LabelElement.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/inc/Form/LabelElement.php b/inc/Form/LabelElement.php new file mode 100644 index 000000000..9c8d54277 --- /dev/null +++ b/inc/Form/LabelElement.php @@ -0,0 +1,27 @@ +<?php +namespace dokuwiki\Form; + +/** + * Class Label + * @package dokuwiki\Form + */ +class LabelElement extends ValueElement { + + /** + * Creates a new Label + * + * @param string $label This is is raw HTML and will not be escaped + */ + public function __construct($label) { + parent::__construct('label', $label); + } + + /** + * The HTML representation of this element + * + * @return string + */ + public function toHTML() { + return '<label ' . buildAttributes($this->attrs()) . '>' . $this->val() . '</label>'; + } +} |