October: Form setting for Input.trigger.js does not accept null

Created on 8 Oct 2020  路  13Comments  路  Source: octobercms/october

When in your form setting is something like this:

trigger:
    action: disable
    field: common_text_or_number_field
    condition: value[]

...everything works as expected. "" value is compared with empty text field "" and result is true.

But in this case:

trigger:
    action: disable
    field: dropdown_field
    condition: value[]

... "" is compared with null returned by dropdown and result is false.

I did not find way how to impose null to form field condition setting.

Possible solution

When Input.trigger.js self.triggerConditionValue contains "", add automatically null value too.

Response Needed Bug hacktoberfest

Most helpful comment

@mjauvin is right. I cannot reproduce this issue on 1.1 branch. I tried it only on 1.0.469, where that problem was detected. On monday I will try to upgrade whole project on 1.1 and find, what fixed that issue.

All 13 comments

@Rike-cz do you think you could submit a PR to https://github.com/octobercms/october/blob/develop/modules/system/assets/ui/js/input.trigger.js#L67-L91 to handle dropdown null values better?

@LukeTowers I found very simple way to achieve what I want.

What is another problem - automatically changed dropdowns (via dependsOn) does not trigger any event. It's more complex I think, maybe for @bennothommo eyes and brain.
trigger

@Rike-cz can't you set the price field to automatically trigger based on the product option field as well as the option value field?

@LukeTowers If every _Product option_ has one or more _Option value_, yes, I can. But in marginal case with no option values for product option I will optain enabled _Price_ too. But it's a detail I think.

If @bennothommo would make some changes in dropdowns, I think this is not correct behavior too:
loading
Changing of value in dropdown fires loading indicators not only in his own dependents.

@Rike-cz could you make a separate issue for that, so it doesn't get lost here? I assume that's based on dependsOn.

Sorry! #5311

I tried reproducing the behavior you describe and couldn't do it. It's working as I would expect, disabling the field using the trigger on another field of type dropdown.

Maybe branch 1.1 does not exhibit this problem?

@mjauvin Have you the second dropdown depending on first one? And trigger of third field focused on second dropdown (cascade)? Yes, you can focus them on first dropdown and it would work until the second dropdown returns null, because this setup enables third field too and it's unintended.

I tried it in 1.0.469, but 1.0 was the same.

@Rike-cz I don't understand why you're talking about cascade here, that was never mentioned in the original issue description. And yes, my dropdown field depends on the other dropdown.

Also, note that 1.0.469 is the same as 1.0. can you try to reproduce on 1.1 branch without applying this PR?

@mjauvin is right. I cannot reproduce this issue on 1.1 branch. I tried it only on 1.0.469, where that problem was detected. On monday I will try to upgrade whole project on 1.1 and find, what fixed that issue.

@Rike-cz we'll wait for your results upon upgrading to 1.1 before reviewing this further.

@bennothommo, @mjauvin Please forget it. After upgrade to 1.1 it works as expected without my PR. I am sorry for making problems :-(

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jvanremoortere picture jvanremoortere  路  3Comments

m49n picture m49n  路  3Comments

dunets picture dunets  路  3Comments

LukeTowers picture LukeTowers  路  3Comments

SeekAndPwn picture SeekAndPwn  路  3Comments