Excellent video. I am wondering if this approach will work if I have to show different fields based on the first field. I am referring to the Agile Rails book in which, based on payment type, you get different fields. That was implemented using react. Do you think this approach will work for that too?
This is a good solution for a very simple form, but it will brake down when you add a required html attribute to that passcode field, once hidden it will block the submit, unless you also toggle the required attribute. Also you might want to be careful if you select passcode protected, add some value, then switch back to the other option and submit, you could drag through any value still present in the now hidden passcode field.
Hello Mathew! Condiderin a hidden passcode field -> in a real app I think that I would do something like this: # app/models/post.rb: ``` before_create do unless passcode_protected? passcode: nil end end ```
@@SupeRails Good videos by the way, it is very interesting to see how people approach different problems like this. I'm dealing with a country selector that, depending on the country chosen might require a zip code and/or a state.
@@MatthewKennedyUK Country->State->City select episode coming this Thursday (in 2 days) :) [The technology is same as #80, but with some nice validations]
Интересно, но в 14й строке контроллера стоит не проверка на равенство, а присвоение (работает, потому что там всегда true). Да и вообще там условие не нужно, можно было просто else обойтись. Ну и в принципе можно было написать в одну строчку без if: this.outputTarget.hidden = this.inputTarget.value != this.showIfValue Но вообще, спасибо за видео, я рельсами недавно занялся, благодаря вам узнаю много интересного и полезного.
Do you want more episodes on writing and applying StimulusJS controllers?
Definitely. I'd like to have more about Stimulus JS controllers. Your videos set things on fire, go on SupeRails !!!
That one was super helpful man. Thank you
thanks for the video, its reeeeally helpful
else if (this.inputTarget.value = this.showIfValue)
Not == ?
I was wondering about that too. I thought he would put a ternary condition, or just use the condition to set the value.
Yes sure . It will be very helpful. Your videos are awesome
Excellent video. I am wondering if this approach will work if I have to show different fields based on the first field. I am referring to the Agile Rails book in which, based on payment type, you get different fields. That was implemented using react. Do you think this approach will work for that too?
This is a good solution for a very simple form, but it will brake down when you add a required html attribute to that passcode field, once hidden it will block the submit, unless you also toggle the required attribute.
Also you might want to be careful if you select passcode protected, add some value, then switch back to the other option and submit, you could drag through any value still present in the now hidden passcode field.
Hello Mathew!
Condiderin a hidden passcode field -> in a real app I think that I would do something like this:
# app/models/post.rb:
```
before_create do
unless passcode_protected?
passcode: nil
end
end
```
@@SupeRails Good videos by the way, it is very interesting to see how people approach different problems like this.
I'm dealing with a country selector that, depending on the country chosen might require a zip code and/or a state.
@@MatthewKennedyUK Country->State->City select episode coming this Thursday (in 2 days) :)
[The technology is same as #80, but with some nice validations]
Интересно, но в 14й строке контроллера стоит не проверка на равенство, а присвоение (работает, потому что там всегда true). Да и вообще там условие не нужно, можно было просто else обойтись. Ну и в принципе можно было написать в одну строчку без if: this.outputTarget.hidden = this.inputTarget.value != this.showIfValue
Но вообще, спасибо за видео, я рельсами недавно занялся, благодаря вам узнаю много интересного и полезного.
Very nice video... how to do with a boolean selector ? I'm searching everywhere and nothing...
question is not clear, but if you mean a boolen type as the values field, then it's declared like static values = { myValue: Boolean }.
Thanks!