[TikiWiki-commits] [Git][tikiwiki/tiki][master] [ENH] add label as placeholder support to select-based and TextArea fields

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69d7fb3fd0528_3b19773822036@gitlab-sidekiq-low-urgency-cpu-bound-v2-67f7658db8-zqxtq.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
a47b9789 by Olivier Kango at 2026-04-09T19:09:48+00:00
[ENH] add label as placeholder support to select-based and TextArea fields
---
* [FIX] tracker placeholders: restore translatable Select + translated field name

* [FIX] trackerinput: use single translatable placeholder for label-as-placeholder

* [FIX] force Element Plus select placeholder to Bootstrap secondary gray

* [FIX] issue labelasplaceholder option on TextArea field

* Remove placeholder in Language.php

* Fix error type in GroupSelector.php

* remove group selector

* add labelasplaceholder support to TextArea field

* [ENH] add labelasplaceholder support to select-based fields

See merge request tikiwiki/tiki!9972

- - - - -


7 changed files:

- lib/core/Tracker/Field/CountrySelector.php
- lib/core/Tracker/Field/Dropdown.php
- lib/core/Tracker/Field/TextArea.php
- templates/trackerinput/countryselector.tpl
- templates/trackerinput/dropdown.tpl
- templates/trackerinput/textarea.tpl
- themes/base_files/scss/_tiki-trackers.scss


Changes:

=====================================
lib/core/Tracker/Field/CountrySelector.php
=====================================
@@ -131,6 +131,17 @@ class Tracker_Field_CountrySelector extends \Tracker\Field\AbstractItemField imp
                             'value' => 't'
                         ],
                     ],
+                    'labelasplaceholder' => [
+                        'name' => tr('Use label as placeholder'),
+                        'description' => tr('Display the field name as a placeholder in the input field instead of separate label.'),
+                        'deprecated' => false,
+                        'filter' => 'int',
+                        'default' => 0,
+                        'options' => [
+                            0 => tr('No'),
+                            1 => tr('Yes'),
+                        ],
+                    ],
                 ],
             ],
         ];


=====================================
lib/core/Tracker/Field/Dropdown.php
=====================================
@@ -31,6 +31,17 @@ class Tracker_Field_Dropdown extends \Tracker\Field\AbstractItemField implements
                         'count' => '*',
                         'legacy_index' => 0,
                     ],
+                    'labelasplaceholder' => [
+                        'name' => tr('Use label as placeholder'),
+                        'description' => tr('Display the field name as a placeholder in the input field instead of separate label.'),
+                        'deprecated' => false,
+                        'filter' => 'int',
+                        'default' => 0,
+                        'options' => [
+                            0 => tr('No'),
+                            1 => tr('Yes'),
+                        ],
+                    ],
                 ],
             ],
             'D' => [
@@ -49,6 +60,17 @@ class Tracker_Field_Dropdown extends \Tracker\Field\AbstractItemField implements
                         'count' => '*',
                         'legacy_index' => 0,
                     ],
+                    'labelasplaceholder' => [
+                        'name' => tr('Use label as placeholder'),
+                        'description' => tr('Display the field name as a placeholder in the input field instead of separate label.'),
+                        'deprecated' => false,
+                        'filter' => 'int',
+                        'default' => 0,
+                        'options' => [
+                            0 => tr('No'),
+                            1 => tr('Yes'),
+                        ],
+                    ],
                 ],
             ],
             'R' => [


=====================================
lib/core/Tracker/Field/TextArea.php
=====================================
@@ -108,7 +108,21 @@ class Tracker_Field_TextArea extends Tracker_Field_Text
                         ],
                         'legacy_index' => 9,
                     ],
-
+                    'labelasplaceholder' => [
+                        'name' => tr('Use label as placeholder'),
+                        'description' => tr('Display the field name as a placeholder in the input field instead of separate label.'),
+                        'deprecated' => false,
+                        'filter' => 'int',
+                        'default' => 0,
+                        'options' => [
+                            0 => tr('No'),
+                            1 => tr('Yes'),
+                        ],
+                        'depends' => [
+                            'field' => 'wysiwyg',
+                            'value' => 'n',
+                        ],
+                    ],
                 ],
             ],
         ];


=====================================
templates/trackerinput/countryselector.tpl
=====================================
@@ -1,9 +1,9 @@
 {if $field.options_map.inputtype eq 't'}
     {jstransfer_list data=$field.flags defaultSelected=$field.value fieldName="{$field.html_name}" filterable=$field.options_map.filterable filterPlaceholder=$field.options_map.filterPlaceholder sourceListTitle=$field.options_map.sourceListTitle targetListTitle=$field.options_map.targetListTitle ordering=$field.options_map.ordering cardinalityParam=$field.validationParam validationMessage=$field.validationMessage}
 {else}
-    <select class="form-select" name="{$field.html_name}" {{if $field.options_map.multiple }}multiple="multiple"{{/if}}>
-        {if $field.isMandatory ne 'y' || empty($field.value)}
-            <option value=""{if $field.value eq '' or $field.value eq 'None'} selected="selected"{/if}>&nbsp;</option>
+    <select class="form-select{if !empty($field.options_map.labelasplaceholder)} labelasplaceholder{/if}" name="{$field.html_name}" {{if $field.options_map.multiple }}multiple="multiple"{{/if}}>
+        {if $field.isMandatory ne 'y' || empty($field.value) || !empty($field.options_map.labelasplaceholder)}
+            <option value="" {if !empty($field.options_map.labelasplaceholder)}disabled {if $field.value eq '' or $field.value eq 'None'}selected{/if} hidden{/if}{if empty($field.options_map.labelasplaceholder) and ($field.value eq '' or $field.value eq 'None')} selected="selected"{/if}>{if !empty($field.options_map.labelasplaceholder)}{tr}Select{/tr} {$field.name|tra|escape}{else}&nbsp;{/if}</option>
         {/if}
         {if empty($field.itemChoices)}
             <option value="Other"{if $field.value eq 'None'} selected="selected"{/if}{if $field.options_array[0] ne '1'} style="background: url('img/flags/Other.png') no-repeat;padding-left:25px;padding-bottom:3px;"{/if}>{tr}Other{/tr}</option>


=====================================
templates/trackerinput/dropdown.tpl
=====================================
@@ -33,9 +33,9 @@
         {/if}
         <input type="hidden" name="{$field.ins_id}_old" value="{$field.value|escape}">
     {else}
-        <select name="{$field.html_name|escape}" class="form-select{if $field.type eq 'D'} group_{$field.ins_id|escape}{/if}">
-            {if $field.isMandatory ne 'y' || $field.value eq ''}
-                <option value=""></option>
+        <select name="{$field.html_name|escape}" class="form-select{if $field.type eq 'D'} group_{$field.ins_id|escape}{/if}{if !empty($field.options_map.labelasplaceholder)} labelasplaceholder{/if}">
+            {if $field.isMandatory ne 'y' || $field.value eq '' || !empty($field.options_map.labelasplaceholder)}
+                <option value="" {if !empty($field.options_map.labelasplaceholder)}disabled {if $field.value eq ''}selected{/if} hidden{/if}>{if !empty($field.options_map.labelasplaceholder)}{tr}Select{/tr} {$field.name|tra|escape}{/if}</option>
             {/if}
             {foreach $field.possibilities as $value => $label}
                 {if $value !== 0  and ($value eq 'other' or $value eq "{tr}other{/tr}")}


=====================================
templates/trackerinput/textarea.tpl
=====================================
@@ -31,14 +31,15 @@
                     {toolbars qtnum=$field.fieldId area_id=$data.element_id section="trackers"}
                 </div>
             {/if}
-            <input type="text" id="{$data.element_id|escape}" name="{$field.ins_id}"{if $field.options_map.width > 0} size="{$field.options_map.width}"{/if}{if $field.options_map.max gt 0} maxlength="{$field.options_map.max}"{/if} value="{$field.value|escape}" onkeyup={$data.keyup} />
+            <input type="text" id="{$data.element_id|escape}" name="{$field.ins_id}"{if $field.options_map.width > 0} size="{$field.options_map.width}"{/if}{if $field.options_map.max gt 0} maxlength="{$field.options_map.max}"{/if} value="{$field.value|escape}"{if $field.options_map.labelasplaceholder} placeholder="{$field.name|escape}"{/if} onkeyup={$data.keyup} />
         {else}
             {if $field.options_map.wysiwyg == 'y'}
                 {textarea _class='form-control' id=$data.element_id name=$field.ins_id rows=$data.rows _toolbars=$data.toolbar onkeyup=$data.keyup _wysiwyg='y' section='trackers' switcheditor='n' _preview=$tracker_previews}
                     {$field.value}
                 {/textarea}
             {else}
-                {textarea _class='form-control' id=$data.element_id name=$field.ins_id _toolbars=$data.toolbar rows=$data.rows onkeyup=$data.keyup _wysiwyg='n' section="trackers" switcheditor='n' _preview=$tracker_previews}
+                {assign var='textarea_placeholder' value=($field.options_map.labelasplaceholder ? $field.name : '')}
+                {textarea _class='form-control' id=$data.element_id name=$field.ins_id _toolbars=$data.toolbar rows=$data.rows onkeyup=$data.keyup _wysiwyg='n' section="trackers" switcheditor='n' _preview=$tracker_previews placeholder=$textarea_placeholder}
                     {$field.value}
                 {/textarea}
             {/if}


=====================================
themes/base_files/scss/_tiki-trackers.scss
=====================================
@@ -314,3 +314,9 @@
     color: #e2e8f0;
   }
 }
+
+el-select {
+  --tiki-input-placeholder-color: var(--bs-secondary-color, #6c757d) !important;
+  --el-text-color-placeholder: var(--bs-secondary-color, #6c757d) !important;
+  --el-input-text-color: var(--bs-secondary-color, #6c757d) !important;
+}



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/a47b9789b808ec10e88053ad859c7074f8d5b2e2

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/a47b9789b808ec10e88053ad859c7074f8d5b2e2
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.