Closed mrpaulharris closed 3 years ago
Hi,
That all falsish values are set to 'zero' is a desired behavior.
But you can set a default FALSE/TRUE Value
{ type: 'checkbox', trueValue:'YES', falseValue:'NO' }
hope this will help and with thanks for your acknowledgement wotamann
@wotamann thanks for the falseValue:'NO' tip.
I can't seem to set it so that the falseValue is false
. I tried:
{type: 'checkbox', falseValue: 'false' }
{type: 'checkbox', falseValue: false }
But neither worked.
Taking a quick look at your source code, it looks like you convert false values to null, even if I do use the vuetify false-value=false
?
You are right, onInput()
sets a false of the checkbox to null
and this is not an intended behaviour.
I will accept your PR #97
The onInput() method harmonizes undefined or empty strings => null, because 'clearable' in vuetify controls resets to null and not to empty string.
Expected Values: true, false
Checkboxes are typically expected to have values true, false:
Actual Values: true, null
However the vuetify-form-base examples show that check box values are true, null.
Why is this a problem?
This behaviour is causing a error when I try to pass checkbox values to an external api that I am using. It is complaining that null is not a valid boolean value.
Attempted workarounds
I tried adding fromCtrl and toCtrl. The lazyvalue is altered but model object deep value is still null.
I also tried an input listener, but I couldn't figure out how to change the value there either.
Successful workaround
The following workaround will directly update the model object (
config
) for all checkboxes on the form.Add an input listener
with change method as follows:
The value of
key
is a string representing the nested property in the object (eg "parent1.parent2.property"). The methodsetPath()
sets the property based on that string (eg this.config.parent1.parent2.property = false).Hope that helps someone having the same issue.
Question
If the true, null behaviour is the way it is supposed to be, how can the null value be transformed to false?
PS: Love this component you have created, thank you!