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

UserForms 0.2


Go to End


185 Posts   48315 Views

Avatar
Juanitou

Community Member, 323 Posts

8 July 2009 at 2:26am

Edited: 10/07/2009 5:03pm

As reported by Kateh, translated forms are not working when upgrading: no fields can be added and no email recipients (error: I can't handle sub-URLs of a CMSMain object).

Nevertheless, you can create a new translation of the form and adding fields should work, the problem is you can't see them in the published page.

SOLUTION: Changing by hand the ParentID of the fields in the EditableFormField table. I'm sure willr will correct the faulty code in a blink!

Avatar
Paschka

Community Member, 4 Posts

8 July 2009 at 2:38am

Edited: 10/07/2009 5:03pm

Didn't solve my problem. switched everthing back to en_US. Still a white page with Submit-Button and no fields

Avatar
Juanitou

Community Member, 323 Posts

8 July 2009 at 3:57am

Edited: 10/07/2009 5:03pm

Hi!

In order to work it here with 2.3.2, I downloaded several days ago userforms trunk (80961). Then I created a new contact form in the default language, then a translation, then Email recipients for both. Finally I manually updated the ParentID in EditableFormField table and the FormID in the UserDefinedForm_EmailRecipient table.

That's all. Kate, did you tried starting from scratch and manually updating the database?

Good luck,
Juan

Avatar
Thermalzombie

Community Member, 27 Posts

9 July 2009 at 7:21pm

Edited: 10/07/2009 5:03pm

Hi can somebody post a new link none seem to work? does it come with updated install instructions.

Avatar
Willr

Forum Moderator, 5523 Posts

9 July 2009 at 7:23pm

Edited: 10/07/2009 5:03pm

Avatar
Big Bang Creative

Community Member, 92 Posts

9 July 2009 at 10:08pm

Edited: 10/07/2009 5:03pm

I'm not sure if this is possible.... I want to change the html outputted by the form. I'd really like to put the form filelds in an unordered list. How easy would this be to do?

Avatar
Juanitou

Community Member, 323 Posts

10 July 2009 at 3:25am

Edited: 10/07/2009 5:03pm

Hi!

It's quite easy, I've just done it, but I'm quite sure it can be done even easier.

In /templates/email/ folder you have SubmittedFormEmail.ss, where you can use something like:

<% control Fields %>
  <ul>
	<li><span class="emphasis">$Title</span>:
			<% if Value = on %>
			Yes
			<% else %>
			$Value
			<% end_if %>
	</li>
  </ul>
<% end_control %>

If you want to use specific templates, the only way I have found is to to create a new Page type where you subclass UserDefinedForm, UserDefinedForm_controller and Email (look at UserDefinedForm.php). In MyFantasticUserDefinedForm_controller you must have a process() method where you replace:

	$email = new UserDefinedForm_SubmittedFormEmail($submittedFields);                     

…with the name of the custom Email subclass.

In this custom process() method you can add data to your email template via the $emailData array, e.g.:

	$emailData = array(
		"Sender" => Member::currentUser(),
		"Fields" => $submittedFields,
		// Added for sending different messages to clients and admin
		"ForAdmin" => true
	);

Then, for example where it says later:
	if($recipient->SendEmailFromFieldID) {
		
		// Used in template if for hiding form fields from clients
		$emailData['ForAdmin'] = false;

Then, in your custom email template:
	<h2>$Subject</h2>
	$Body
	<% if ForAdmin %>
	<% control Fields %>
	<p>
		<span class="emphasis">$Title</span></br>
		<% if Value %>
		<% if Value = --choissisez-- %>
		<span style="color:red">Non renseigné</span>
		<% else %>
		$Value
		<% end_if %>
		<% else %>
		<span style="color:red">Non renseigné</span>
		<% end_if %>
	</p>
	<% end_control %>
	<% end_if %>

In this way, the admin receives a message with all the fields of the form and the client only a message with the $Body defined in the CMS, for example saying ‘Form received, thanks!’.

Hope it helps,
Juan

Avatar
Juanitou

Community Member, 323 Posts

10 July 2009 at 3:26am

Edited: 10/07/2009 5:03pm

By the way, willr, when we could use complex values in template controls? I had to do all this ForAdmin trick because I cannot simply put something as:

<% if To = admin@mysite.com %>

The @ breaks the parser. Also, I have to use, for field values, the kind of ‘--choissisez--’ (‘--choose--’), all in ASCII, instead of a word or several of them containing ‘special’ chars as é, ç or ñ, or even an space.

Well, that's not the fault of userforms…

Best regards,
Juan

Go to Top