Interconnected field

Is something like this possible?
When we select female in the sex section, castrated selection option is invisible and it appears when we select male.
Can I link the fields together?


Some related thoughts have been floating around for a while: I would actually love to remove the “Castrated” field entirely, and instead make it a log-driven state somehow. In other words: rather than setting “Is castrated” on the animal level directly, you would record a log that sets the state to “Is castrated” much like “Location” and “Group membership” is set via log.

The “Castrated” field was added very early in farmOS, and it feels a bit out of place in my mind, to be honest.

Your suggestion to toggle it based on the selected “Sex” does make sense, given it’s current placement, though I agree. It probably wouldn’t be hard to make that hidden/visible via JavaScript if you’d like to give that a try.

Can we add a module like Conditional Fields? I added one but it does not come when creating form.


1 Like

Do you mean this?

Sure it looks like that might be capable of doing what you describe.

We will not be including this as a dependency of farmOS itself, but if you are self-hosting you are free to experiment with any modules you’d like! This looks like one that would be safe to try, because it doesn’t affect the data storage at all, as far as I can tell (you just want to be careful with any modules that might cause trouble for you when it comes time to upgrade to farmOS 2.x).

Thank you. it will solve my problem.

1 Like