Question

I am using Drupal 6.28 with Webform 6.x-3.18. I have a multi-step form setup. Some of my fields only show up if you select a radio button. In this particular instance this is a registration form and one of the questions is "Will you be bringing a guest?". If they select yes, then some additional fields drop down pertaining to their guest. So this works great. They can submit the form and everything works. The problem is, if they go back into their form to edit it and decide to go solo and now they are NOT bringing a guest, the guest fields disappear from the form as expected, but the data is still there behind the scenes and specifically in the database. So now when we go to run reports on some specific guest fields, those fields are throwing our reports off because the data is still there in the dB as if they are bringing a guest even though they are not now.

Can anyone think of the best place to handle this issue? Should I make a custom module that hooks into the webform somehow and catches for it and resets all the guest fields? I just don't know the best place to handle this.

THANKS

Était-ce utile?

La solution

You could have some logic on the submission of the data. If it is the first time they are submitting (not already in DB), go forward as planned. If the data already exists, do a before and after compare on that field in question. If it toggled off you can clear your DB spots for that user.

You could also have something in the form code, so if that radio button is not checked, always insert some blank/null/however you handle it into the DB. This way, it is always writing in those fields as blank even if the data was there before (if you go ahead and rewrite that entire row in the DB anyway).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top