Forums

Bypass a db Save action

chriso0258 31 Jul, 2015
Hello,

On my form I have a textarea box where a user can add comments. In my on Submit event I have a db Save action to save the comments to a table I've set up to store them. The table includes a foreign key to another table as well as the date the form was submitted. A user may not always write a note when completing the form but because of the db Save action, a new record gets created in the comments table when the form is submitted. Is there a way I can bypass the db Save action if the is nothing written in the note box of the form?

Thanks for your insights.
GreyHead 01 Aug, 2015
Answer
Hi chriso0258,

Use an Event switcher action; change the event list to say save_comment, save the action. Add PHP like this
<?php
if ( !empty($form->data['comment']) ) {
  return 'save_comment';
}
?>
Add your second DB Save action to the new save_comment event in the Event Switcher.

Bob
This topic is locked and no more replies can be posted.