TastyIgniter
TastyIgniter copied to clipboard
Selectlist values are not blankable
Raising as an issue instead of a PR as Im not sure how best to handle it.
The issue is that select lists cant be blanked once they have a value, even if they are not required. So to replicate, add a value, then save, then remove the value, and what you saved persists.
Something similar to what have been done with KD? https://github.com/ryanmitchell/ti-ext-kitchendisplay/blob/4a8f1e49fc75fb1222d2e34ba0c6cedcbe0608fd/models/Views.php#L38
Yep that’s my work around. Needs to be handled better in core.
Using the placeholder
field property you can add an empty option.. See the language form field in staff_model.php
Yeah I tried that, it doesnt seem to work with select list - because there is no form field value present it treats the field as missing so doesnt update the value.
Using the language field on the admin staff form as an example.. I'm able to create a staff with multiple languages and then update the same staff with no language selected, so somehow the form field is passing the right value? or am I missing something?
Maybe the difference is that the staff model field is a relation not a select list? I've tried quite a few ways of handling it (and have a work around), but a straight up standard select list cant be blanked.
Ok, share your field configuration
From the loyalty extension I'm working on...
'spending_categories' => [
'tab' => 'lang:igniter.coupons::default.text_tab_restrictions',
'label' => 'lang:igniter.coupons::default.label_categories',
'type' => 'selectlist',
'options' => \Admin\Models\Categories_model::getDropdownOptions(),
],
I see what you mean with the form field value, apart from the workaround in the KD extension, how would you fix this within the field_ selectlist
file?
The only thing I had thought of was adding something around here: https://github.com/tastyigniter/TastyIgniter/blob/1b8315880937c9ba0e58fddd0f38321d438de64b/app/admin/widgets/Form.php#L753
if type is select list and multiple then add a blank value if not present in $data - feels hacky but was the best i could come up with
Ok, I see what you mean with the values but adding the placeholder option actually works, it sends an empty string array as the field value which in turn removes the value from the db
'options[spending_categories]' => [
'tab' => 'lang:igniter.coupons::default.text_tab_restrictions',
'label' => 'lang:igniter.coupons::default.label_categories',
'type' => 'selectlist',
'options' => \Admin\Models\Categories_model::getDropdownOptions(),
'placeholder' => 'please select',
],
Another thing we can do is look into the bootstrap-multiselect js plugin to see if we can send an empty string/array when none is selected.
I see what you mean - you need to select the placeholder value though - if you select nothing is comes through blank? Doesnt seem intuitive to me. I'll look into the JS library and see if there is a way of always passing a value.
Another related issue is the styling - see how the label from the next field overlaps here:
I couldn't figure out where the z-index was coming from.
Yea the bootstrap-multiselect plugin is a bit messy, maybe we can find a replacement for it?
Hmm that seems like a big change this late in the cycle? I think I can make it work by adding a “Select none” option similar to select all - give me a couple of days.
On 24 Jan 2021, at 02:26, Sam Poyigi [email protected] wrote:
Yea the bootstrap-multiselect plugin is a bit messy, maybe we can find a replacement for it?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tastyigniter/TastyIgniter/issues/659#issuecomment-766278810, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMVO2TIXX6MZDWWX4DU4LS3OAOLANCNFSM4V6Z73EQ.
Both issues should be fixed with the PR here: https://github.com/tastyigniter/TastyIgniter/pull/677
This issue will be closed and archived in 3 days, as there has been no activity in the last 60 days. If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue. If this issue is critical to your business, consider the Dedicated Support Service where a Service Level Agreement is offered.