Skip to content

CFM-512_Support_element-spec_rendering_in_htmlInject_form_element #387

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions app/templates/element/form/htmlInject.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/


declare(strict_types=1);

// View vars
// $content - the text or markup to be rendered
// $content - the text or markup to be rendered OR an element spec array
// $type - accepts "subtitle" or "html"
// $vv_action

Expand All @@ -43,7 +42,16 @@
<li class="fields-subsection fields-subsection-<?= $type ?>">
<?php if($type === 'subtitle'): ?>
<h3><?= $content ?></h3>
<?php else: // we have arbitrary HTML ?>
<?= $content ?>
<?php else: ?>
<?php
// If content is an element spec, render it now (after Form->create()).
if (is_array($content) && !empty($content['element'])) {
$params = $content['params'] ?? [];
echo $this->element($content['element'], $params);
} else {
// Otherwise treat as raw HTML/text.
echo $content;
}
?>
<?php endif; ?>
</li>