1

I want to set a value on a field in a CiviCRM webform only when the form is submitted and not when saved as draft. The field is a CiviCRM field that appears in the webform but is not shown to the user.

The reason is I want to allow users to access and edit the information in the webform, but find a way of preventing them from accessing/editing the form once it has been "submitted". So I had created a yes/no field in Civi which I could set to yes when they submit the form and then prevent them from accessing the form if the value for the field was yes.

I was trying to set the value of the field using hook_webform_submission_presave but kept on getting errors. Not sure if this was because the form is split up into several pages and is using the "Save Draft" functionality. I'm not sure also if this is the right approach for CiviCRM enabled webforms.

This webform could be for either creating a new CiviCase record or editing an existing one.

Am open to suggestions of any other ways of preventing users from accessing the form after they have already submitted it.

I am using CiviCRM 5.3.1 with Drupal 7.59.

2

I managed to get this to work by creating a custom text field in Civi. I then included this text field in the webform as a hidden component and set a default value. This value then gets set (for the text field) only when the form is submitted. I can then test the field to see if it has the set value or not and use this to hide or block the webform from the user.

0

There are Drupal permissions that can prevent certain Roles seeing Submitted forms which may deal with "The reason is I want to allow users to access and edit the information in the webform, but find a way of preventing them from accessing/editing the form once it has been "submitted".

  • Thanks for the suggestion Pete, I did have a look at this but couldn't get it to work. I think I have found a fairly simple solution. I can create a custom text field which can be hidden on the form and have a default value set in the webform (not Civi) that gets set when the form is submitted. Then I can tell if the form has been submitted or not. I had tried this with a radio select field and couldn't get it to work, but I have got a straight text field to work. – Ben Sep 28 '18 at 12:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.