The system I'm working this is based around users and charity accounts, everyone has a user account but charities have a user account and a charity record tied to the user account with a user id that contains some extra fields.
I need one registration form that allows people to sign up as either an individual (with just a user account) or a charity (user account + charity record) so I've embedded the charity form into my user registration form and added a radio button question at the top to find out which type of account the user is signing up for.
What I need is that when the user indicates they want a charity account for the charity fields to become required and when they indicate they want to be an individual for them to not be (I hide them with Javascript when they select this).
I've tried running this when the user selects charity but it doesn't seem to work:
$this->register_form->getEmbeddedForm('charity')->getValidator("name")->setOption("required", true)
Can anyone let me know what the correct way to do this is?