From bd9ddfb0d2da552876686695f9b63ee3d6486a49 Mon Sep 17 00:00:00 2001 From: tp_dhu Date: Tue, 25 Mar 2025 09:16:32 +0000 Subject: [PATCH] updated BulmaFormHelper with H_FIELD_SELECT_NEW - allowing the creation of horizontal fields using template extension --- app/extensions/BulmaFormHelper.php | 56 ++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/app/extensions/BulmaFormHelper.php b/app/extensions/BulmaFormHelper.php index b79e05b..f3da274 100644 --- a/app/extensions/BulmaFormHelper.php +++ b/app/extensions/BulmaFormHelper.php @@ -5,21 +5,26 @@ class BulmaFormHelper extends \Prefab { const H_FIELD_INPUT = 1; const H_FIELD_TEXTAREA = 2; const H_FIELD_SELECT = 3; + const H_FIELD_SELECT_NEW = 4; - static public function render($args) { + static public function render($node) { + + $attr = $node['@attrib'] ?? []; + $type = strtoupper($attr['type']) ?? null; - $type = strtoupper($args['@attrib']['type']); // all * - $label = $args['@attrib']['label']; - $name = $args['@attrib']['name']; - $value = isset($args['@attrib']['value']) ? $args['@attrib']['value'] : ''; + $label = $attr['label']; + $name = $attr['name']; + $value = isset($attr['value']) ? $attr['value'] : ''; // select - $options = isset($args['@attrib']['options']) ? $args['@attrib']['options'] : ''; - $selected = isset($args['@attrib']['selected']) ? $args['@attrib']['selected'] : ''; + $options = isset($attr['options']) ? $attr['options'] : ''; + $selected = isset($attr['selected']) ? $attr['selected'] : ''; // + $label = \Template::instance()->build($label); $name = \Template::instance()->build($name); $value = \Template::instance()->build($value); + $options_array = \Template::instance()->token($options); if(defined("BulmaFormHelper::$type")){ @@ -35,6 +40,9 @@ class BulmaFormHelper extends \Prefab { case BulmaFormHelper::H_FIELD_SELECT: return BulmaFormHelper::build_h_field_select($label, $name, $options, $selected); break; + case BulmaFormHelper::H_FIELD_SELECT_NEW: + return BulmaFormHelper::build_h_field_select_new($attr); + break; default: return '
Error: Bulma CSS Form TYPE ('.$type.') not defined.
'; break; @@ -46,6 +54,40 @@ class BulmaFormHelper extends \Prefab { } + static function build_h_field_select_new($attr) + { + $f3 = \Base::instance(); + + $label = $attr['label'] ?? ''; + $name = $attr['name'] ?? ''; + $options_arr = $attr['options'] ?? []; + $optionValue = $attr['option_value'] ?? 'id'; + $optionName = $attr['option_name'] ?? 'name'; + $selected = $attr['selected'] ?? ''; + + $options = $f3->get($options_arr); + + $html = '
'; + if (!empty($label)) { + $html .= ''; + } + $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= '
'; + + return $html; + } + static function build_h_field_input($label, $name, $value){ $string = '