![]() |
form_dropdown() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: form_dropdown() (/showthread.php?tid=80457) |
form_dropdown() - 68thorby68 - 11-03-2021 Hi all, Does anyone know is there is a way to place additional attributes to the option tag in a Select dropdown, using the form_dropdown() form helper? I am trying to achieve a out put like this Code: <select class="floating-select" name="tam_day_label" id="tam_day_label" onclick="this.setAttribute(\'value\', this.value);" value=" " required/> my current form dropdown (select) is compiled like below: Controller PHP Code: $dayArray=[ PHP Code: <?= form_dropdown('tam_day_label', $dayArray, old('tam_day_label'), $dayType_tags); ?> Output Code: <select class="floating-select" name="tam_day_label" id="tam_day_label" onclick="this.setAttribute(\'value\', this.value);" value=" " required/> Many thanks. RE: form_dropdown() - includebeer - 11-05-2021 The easiest way to know is looking at the code: https://github.com/codeigniter4/CodeIgniter4/blob/develop/system/Helpers/form_helper.php#L267 The short answer: it's not possible. Anyway, I'm not sure how it could be implemented since it takes a simple key/value array as input for the options. RE: form_dropdown() - 68thorby68 - 11-09-2021 Thank you includebeer. I toyed with this for quite a while, obviously with no luck and thought I was missing something. I will have to take a different approach, but isn't that half the fun? Again, many thanks |