#12 - form live preview

This commit was merged in pull request #14.
This commit is contained in:
Martin Slachta
2026-06-14 14:13:37 +02:00
parent 0fc0addf47
commit 2890a9b993
8 changed files with 375 additions and 32 deletions
+24
View File
@@ -194,6 +194,30 @@ class RsvFormBuilder
return $this->row($id, $label, $ctrl, $desc);
}
/**
* Syntax-highlighted editor backed by WordPress' bundled CodeMirror.
*
* Serializes exactly like {@see textarea()} — the underlying <textarea>
* stays the source of truth.
*
* @param string $mode MIME type for highlighting, e.g. 'text/html'.
*/
public function code(
string $id,
string $label,
string $desc = '',
string $value = '',
string $mode = 'text/html',
int $rows = 8
): static {
$ctrl = RsvCodeEditor::render($id, [
'value' => $value,
'mode' => $mode,
'rows' => $rows,
]);
return $this->row($id, $label, $ctrl, $desc);
}
public function custom(string $label, callable $fn) : static {
$this->rows[] = '<tr>'
. '<th>' . esc_html($label) . '</th>'