I have two channel_fields that can be filled, and I need one of these values to be required (but not both).
Is there fieldtype that can solve this problem?
NB Only one of the fields needs to be filled. I don't want to set both fields as required.
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It only takes a minute to sign up.Sign up to join this community
So the short answer is, I'm not aware of an existing fieldtype that would do this at the moment.
However if you know a little PHP and you're willing to get your hands dirty it would be pretty easy to create something custom, depending on your validation requirements.
The full in's and out's of doing so go beyond the scope of this answer, but here's a summary of the approach I'd take:
The easiest thing would be too start with an existing compound field fieldtype (ie a fieldtype that outputs a group of fields in the CP). I'd probably start with VZ Address as the source is pretty readable and it's CC Share-Alike licensed.
You'd essentially just need to take the VZ Address FT and:
validate()method that checks that at least one of the fields is not empty.
PS If you need help with this hit me up on chat or Twitter, and I'll do my best to help you out.