I am using PloneFormGen 1.7.12 in Plone 4.3.3. I have a large selection field that contains about 20 names. It is required. If the user picks one of the names, it should send them to a Plone Page template that has instructions for them. If it picks any other page, it should send the user an email with their form results and takes them to a thank you page.
I have tried doing this with a python script, but what I am doing doesn't work. The code in the script is:
REDIRECT = context.REQUEST.RESPONSE.redirect
URL=context.REQUEST.URL1 + '/'
FORM=context.REQUEST.form
school_name = context.REQUEST.form['school_name']
member = context.portal_membership.getAuthenticatedMember()
roles=member.getRolesInContext(context)
if school_name <> "Other-School not Listed":
return False
else:
return REDIRECT(URL + 'not_listed')
I put python:here.school_redirect() in the Custom Form Action override, but the URL displays:
python:here.school_redirect()
and the page displays "The address wasn't understood"
school_redirect is the id of the python script not_listed is the id of the Plone page template school_name is the id of the select field
Any suggestions are greatly appreciated.
Joe Bigler
The
Custom Form Actionis a simple StringField, no a TALES expression field.This means you can add
./school_redirectto theCustom Form Action, but then you got other issues like returningFalsewill not work, you need to redirect anyway. You also bypasses all validators and success handlers.So imho another approach may be better:
1. Override the success handler
Custom Success ActionField on FormFolder. You may add a single expression or a python script, which returns the right value.Field description:
Your
./school_redirectneeds only small changes to fit for this solution. Do not redirect yourself, just return the right id (of a page template/view/etc.)2. Do not trigger the mail adapter
For this purpose the Mail-Adapter provides a field called
Execution Condition.Add a script or expression, which evaluates if the email needs to be triggered or not.
You may reuse the
./school_redirectscript to compose the expression:python: here.school_redirect() != 'not_listed'