if.. else.. in form

geejay 04 Aug, 2014
Hello,

I need advice in how to implement the following. Before the form is rendered, I need to check a database record. If true, a message is displayed, if not the form is then displayed. It essentially is an event registration for register users and I want to prevent any user from submitting twice. So on submit I will have the database record updated that is checked at the beginning. I hope that makes sense.

In the old Chronoforms, I just did this all in the form code. Now with the new version it seems more modular and it looks like I need to do this in the setup tab, but not sure how to implement this if...else... Any ideas?

Thanks!
GreyHead 04 Aug, 2014
Hi geejay,

What exactly are you going to check before the form loads?

Bob
geejay 04 Aug, 2014
It is going to check in the CB table (yes/no field) whether the user is registered already (via the form). If "yes", then I want to display a message that their registration is confirmed along with some other info, if not then the registration form prints out.

If a user submits the form, I then have an onsubmit action that marks the field yes in the CB table (comprofiler).
GreyHead 04 Aug, 2014
Hi geejay,

I think I would do this using a Custom code action in the On Load event to check the CB database table and set a form data variable accordingly e.g. $form->data['is_registered'].

In the Designer tab I'd use two containers and display them (or not) depending on the $form->data['is_registered'] value. Set the Container to Type 'Custom' and then you can use PHP in the Start/End code boxes to hide or show it.

Bob
geejay 04 Aug, 2014
Hey Bob - Thanks I appreciate you taking the time to give me some pointers. I was just coming back to say I think I figured it out using the Event Switcher. Seems to work.🙂 If not I will give your route a go!

All the best, I am sure I will be back🙂
This topic is locked and no more replies can be posted.