Making member properties compulsory
<VasudevaService-K9y3B4ipJAZZAIG4hdpdiNBPR1lH4CV8@public.gmane.org> (Dhyani) Sun, 28 Mar 2004 12:08:18 +0200
| Newsgroups | gmane.org.misc.vasudeva-server.web |
|---|---|
| Message-ID | <[email protected]> |
To all who care for member properties....
In a previous message, I described how to add custom memberdata properties
to the Plone system. These are the properties that every Member can edit by
going to "my preferences" / "Personal Preferences". As a sample, I added
the "gender" property. What was missing was: how to make these compulsory -
meaning that if a user doesn't specify a value, he will get a nice error
message when he tries to save his input, prompting him to specify the
missing property.
So, I made the "gender" property compulsory. In order to test it, go to
http://www.vasudevaserver.org:7091/Dhyani, log in and go to my preferences /
Personal Preferences. Then try to be neutral - choose the empty option in
the Gender dropdown. Click on Save. See what happens.
Next, I tried to edit my previous How-To that Priyadarshan had made into a
fishbowl entry, so that in its last step it would be explained how to make
the new property compulsory. Unfortunately, I can't find it there anymore!
Something must have changed there considerably. Priyadarshan, could you
please add the following description to this How-To, and also tell me where
I can find it? Thanks!
*************************************************
Step xxx: How to make the gender property compulsory:
*************************************************
Go to portal_skins/custom/personalize_form and click on the Validation tab.
In the Section "Edit Default Validators", where you see the string
"validate_emailaddr, validate_personalize", insert validate_gender:
validate_emailaddr, validate_personalize, validate_gender
Click on "Save"!
Now go to the script portal_skins/plone_form_scripts/validate_emailaddr,
click on Customize, then go to portal_skins/custom and rename this script to
validate_gender. Go inside this script and change the title to "Validates
gender" (instead of "Validates an email") and the Parameter List to
gender='' (instead of email=''). Then delete all its code and insert the
following instead:
reg_tool=context.portal_registration
def invalid(field):
state.setError('gender', 'You did not enter a gender.',
'invalid_gender')
if gender:
pass
else:
invalid('gender')
if state.getErrors():
return state.set(status='failure', portal_status_message='Please correct
the indicated errors.')
else:
return state
And do not forget to have the following attribute set in the field
definition of the gender (inside personalize_form):
tal:attributes="class python:test(error, 'field error', 'field')"
--------------------------------------------------------------------------
This message is sent to you because you are subscribed to the mailing list <VasudevaService-K9y3B4ipJAZZAIG4hdpdiNBPR1lH4CV8@public.gmane.org>.