Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Extending Userforms - tracking users, only allow one attempt


Go to End


2 Posts   684 Views

Avatar
JonShutt

Community Member, 244 Posts

27 September 2011 at 11:49am

Hello,

I'm using the userforms module ( which is excellent! ) for a membership site. The concept is people create an account, log in, and get given a few questionaires/tests.

What I need is

> only allow a user to complete the form one time
> the site owners need to be able to find a client in the CMS and view the results of forms they've submitted

ideally it would be nice if I could extend the 'options' tab in the form to have 3 options:
> allow unlimited submissions | allow one submission | user can return and edit form

Any suggestins welcome

Thanks

Avatar
JonShutt

Community Member, 244 Posts

27 September 2011 at 12:33pm

Ok, i've got one part working by created this function in page.php

public function FormSubmittedAlready() {
$MemberID = Member::currentUser()->ID;
return DataObject::get('SubmittedForm', "`SubmittedByID` = '$MemberID' and `ParentID` = '$this->ID' ");
}

and then putting this in page.ss

<% if FormSubmittedAlready %>
<p>You have already submitted this form</p>
<% else %>
$Form
<% end_if %>

however, i had to remove $UserDefinedForm from the CMS field, to force the form to default to using the $Form area in the template. this means i've lost the abilty to control where the form is...

still looking for solutions to the other parts...