diff --git a/app/extensions/BulmaFormHelper.php b/app/extensions/BulmaFormHelper.php
index 184bf43..4b8fab8 100644
--- a/app/extensions/BulmaFormHelper.php
+++ b/app/extensions/BulmaFormHelper.php
@@ -9,6 +9,7 @@ class BulmaFormHelper extends \Prefab {
const FIELD_INPUT = 10;
const FIELD_TEXTAREA = 11;
+ const FIELD_SELECT = 13;
static public function render($node) {
@@ -29,6 +30,7 @@ class BulmaFormHelper extends \Prefab {
$label = \Template::instance()->build($label);
$name = \Template::instance()->build($name);
$value = \Template::instance()->build($value);
+ $selected = \Template::instance()->build($selected);
if(defined("BulmaFormHelper::$type")){
@@ -53,6 +55,9 @@ class BulmaFormHelper extends \Prefab {
case BulmaFormHelper::FIELD_TEXTAREA:
return BulmaFormHelper::build_field_textarea($label, $name, $value, $class, $rows);
break;
+ case BulmaFormHelper::FIELD_SELECT:
+ return BulmaFormHelper::build_field_select($attr);
+ break;
default:
return '
Error: Bulma CSS Form TYPE ('.$type.') not defined.
';
break;
@@ -131,6 +136,65 @@ class BulmaFormHelper extends \Prefab {
return $string;
}
+
+ /**
+ * build_field_select_new
+ *
+ * ``
+ *
+ * @param mixed $attr
+ * @return void
+ */
+ static function build_field_select($attr)
+ {
+ $f3 = \Base::instance();
+
+ $class = $attr['class'] ?? '';
+ $label = $attr['label'] ?? '';
+ $name = $attr['name'] ?? '';
+ // $options_arr = $attr['options'] ?? [];
+ $option_value = $attr['option_value'] ?? 'id';
+ $option_name = $attr['option_name'] ?? 'name';
+
+ $options = \Template::instance()->token($attr['options']);
+ $selected = \Template::instance()->token($attr['selected']);
+
+ // TODO: label - this could be moved into a seperate function
+ $html_label = $label !== '' ? sprintf('', $label) : '';
+
+ $tmp_options = 'field_select('.
+ $options.', '.$selected.', "'.$option_value.'", "'.$option_name.'"); ?>';
+
+ $html = '
+
+ ';
+
+ return sprintf($html, $html_label, $tmp_options, $name, $class);
+ }
+
+ function field_select($options, $selected, $option_value, $option_name){
+ $html_options = '';
+ foreach ($options as $option) {
+ $value = $option[$option_value] ?? '';
+ $text = $option[$option_name] ?? '';
+ $html_selected = ((string)$value === (string)$selected) ? ' selected="selected"' : '';
+ $html_option = '';
+ $html_options .= sprintf($html_option, $value, $html_selected, $text);
+ }
+ echo $html_options;
+ }
+
static function build_h_field_select_new($attr)
{
$f3 = \Base::instance();