Save default input value in DDBB

Hi I have a form that is stored as json in de DDBB. The problem is with the default value of a select component. The select have 3 values (To do, In progress, Done), and the To do value is set as default. When i save the form with other two values selected, the select value are stored correctly in the ddbb, but when the default value is selected, it doesn't appear. I need to save the default value because when I search on the json with a Query, i need to give it.
11 Replies
jals65
jals65OP2y ago
Hi, do you know how to do it?
tesse05
tesse052y ago
can yo show the code? sounds weird
jals65
jals65OP2y ago
the select:
Select::make($this->getStatusComponentName())
->options($this->options)
->default(array_keys($this->options[0])
->disablePlaceholderSelection()
->label(false)
->reactive()
Select::make($this->getStatusComponentName())
->options($this->options)
->default(array_keys($this->options[0])
->disablePlaceholderSelection()
->label(false)
->reactive()
$this->options = [ 'to_do' => 'To Do', 'in_progress' => 'In Progress', 'awaiting_block' => 'Awaiting/Block', 'done' => 'Done', ] The problem is when I create or edit an entity by the form, in the $data of mutateFormDataBeforeSave() doesn't appear the select data if default value is selected. and the same in the mutateFormDataBeforeCreate If is not the default value, for example i select Done, it appears correctly
Dan Harrin
Dan Harrin2y ago
are you on the create or edit page
jals65
jals65OP2y ago
In the 2
Dan Harrin
Dan Harrin2y ago
defaults are only filled on create
jals65
jals65OP2y ago
No, i debug in the create, and doesn't appear
jals65
jals65OP2y ago
as you can see, only appear in_progress. There are 2 more selects with default value to_do and it doesn't appear
jals65
jals65OP2y ago
As you can see here, when I select one of three others values, all appear correctly, but when I select the default value, it doesn't appear
jals65
jals65OP2y ago
I have this function to check if the select have value. If i don't have value, there is any way to set the value on the state? Anythink like setState()
jals65
jals65OP2y ago
??
Want results from more Discord servers?
Add your server