#6 - Output elements

This commit was merged in pull request #11.
This commit is contained in:
Martin Slachta
2026-06-14 11:07:14 +02:00
parent 3225ff1e10
commit 0fc0addf47
4 changed files with 220 additions and 1 deletions
@@ -0,0 +1,21 @@
<?php
class RsvOutputTextElementHandler implements RsvFormElementHandler {
private const ALLOWED_TAGS = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
public function draw(RsvFormElementDefinition $def): void {
$raw = $def->getAttr('tag', 'p');
$tag = in_array($raw, self::ALLOWED_TAGS, true) ? $raw : 'p';
echo '<' . $tag . ' class="rsv-form-output-text">' . esc_html($def->getLabel()) . '</' . $tag . '>';
}
public function submit(RsvFormElementDefinition $def, int $submit_id, array $data, RsvFormSubmitResult $result): bool {
return true;
}
public function rollback(RsvFormElementDefinition $def, int $submit_id, array $data, RsvFormSubmitResult $result): void {
// No side effects to undo.
}
}