hi folks,
i have created custom error messages for each of my fields, the good news
is that i don't see system error message and once the user submit my custom
errors appear.
the problem is one i load the page, i see all custom errors set to the
value of "*None*". is there any workaround? i tried to set error fields =''
but didn't work
Thanks in advance
*db.py:*
*db.define_table('t_resumes',*
* Field('f_firstname', 'string', required=True, label='First
Name '),*
* Field('f_lastname', 'string', required=True, label='Last
Name '),*
* Field('f_phonenumber', 'integer', required=True,
label='Phone Number '),*
* Field('f_emailaddress', required=True,unique=True,
label='Email Address '),*
* Field('f_language1', required=True, label='Language '),*
* Field('f_language2', required=False, label='Language '),*
* Field('f_language3', required=False, label='Language '),*
* Field('f_language4', required=False, label='Language '),*
* Field('f_language5', required=False, label='Language '),*
* Field('f_currentemployer','string', required=False,
label='Current Employer '),*
* Field('f_lastemployer', 'string', required=False,
label='Last Employer '),*
* Field('f_educationlevel', 'string', required=False,
label='Education Level '),*
* Field('f_securityclearance', required=True,
label='Security Clearance '),*
* Field('f_militaryexperience',required=True,
label='Military Experience '),*
* Field('f_specialcertifications1', 'string',
required=False, label='Special Certification '),*
* Field('f_specialcertifications2', 'string',
required=False, label='Special Certification '),*
* Field('f_specialcertifications3', 'string',
required=False, label='Special Certification '),*
* Field('f_specialcertifications4', 'string',
required=False, label='Special Certification '),*
* Field('f_specialcertifications5', 'string',
required=False, label='Special Certification '),*
*
Field('f_created_on','datetime',default=request.now,writable=False,readable=False),*
* )*
*de*
*default.py:*
*def resumes(): form=SQLFORM(db.t_resumes, hideerror=True)
db.t_resumes.f_firstname.requires =
[IS_NOT_EMPTY(error_message='Required'), IS_LENGTH(50, error_message='Enter
shorter First Name')] db.t_resumes.f_lastname.requires =
[IS_NOT_EMPTY(error_message='Required'), IS_LENGTH(50,
error_message='Enter shorter Last Name')]
db.t_resumes.f_phonenumber.requires =
[IS_NOT_EMPTY(error_message='Required'), IS_INT_IN_RANGE(0, 9999999999,
error_message='Enter a valid number' )]
db.t_resumes.f_emailaddress.requires = [IS_NOT_EMPTY(),
IS_EMAIL(error_message='invalid email!'), IS_NOT_IN_DB(db,
db.t_resumes.f_emailaddress, error_message='Email already exist or
empty.')] db.t_resumes.f_language1.requires =
[IS_NOT_EMPTY(error_message='Enter at least a language'), IS_LENGTH(25,
error_message='Enter a shorter language')]
db.t_resumes.f_language2.requires = IS_LENGTH(25, error_message='Enter a
shorter language') db.t_resumes.f_language3.requires = IS_LENGTH(25,
error_message='Enter a shorter language')
db.t_resumes.f_language4.requires = IS_LENGTH(25, error_message='Enter a
shorter language') db.t_resumes.f_language5.requires = IS_LENGTH(25,
error_message='Enter a shorter language')
db.t_resumes.f_currentemployer.requires = IS_LENGTH(300)
db.t_resumes.f_lastemployer.requires = IS_LENGTH(300)
db.t_resumes.f_educationlevel.requires = IS_LENGTH(300)
db.t_resumes.f_securityclearance.requires = IS_IN_SET({'Y' : 'Yes', 'N':
'No'}, error_message='select an option')
db.t_resumes.f_militaryexperience.requires = IS_IN_SET({'Y' : 'Yes', 'N':
'No'}, error_message='select an option')
db.t_resumes.f_specialcertifications1.requires = IS_LENGTH(300)
db.t_resumes.f_specialcertifications2.requires = IS_LENGTH(300)
db.t_resumes.f_specialcertifications3.requires = IS_LENGTH(300)
db.t_resumes.f_specialcertifications4.requires = IS_LENGTH(300)
db.t_resumes.f_specialcertifications5.requires = IS_LENGTH(300) if
form.accepts(request.vars,session): session.flash="You resume was
submitted successfully!" redirect(URL(r=request))
#divi=SQLFORM.grid(db.t_resumes) return dict (form=form)*
*resumes.html:*
{{=form.custom.begin}}
<center>
<table class="formstable" border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td width="33%" class="formcell">First Name:</td>
<td width="33%" class="formcell2">
<div>{{=form.custom.widget.f_firstname}}</div></td>
<td width="34%"
class="formcell3">{{=form.errors.f_firstname}}</td>
</tr>
<tr>
<td width="33%" class="formcell">Last Name:</td>
<td width="33%" class="formcell2">
<div>{{=form.custom.widget.f_lastname}}</div></td>
<td width="34%"
class="formcell3">{{=form.errors.f_lastname}}</td>
</tr>
<tr>
<td width="33%" class="formcell">Phone:</td>
<td width="33%"
class="formcell2"><div>{{=form.custom.widget.f_phonenumber}}</div></td>
<td width="34%"
class="formcell3">{{=form.errors.f_phonenumber}}</td>
</tr>
<tr>
<td width="33%" class="formcell">Email Address:</td>
<td width="33%" class="formcell2">
<div>{{=form.custom.widget.f_emailaddress}}</div></td>
<td width="34%"
class="formcell3">{{=form.errors.f_emailaddress}}</td>
</tr>
<tr>
<td width="33%" class="formcell">Language(s):</td>
<td width="33%" class="formcell2">
<div>{{=form.custom.widget.f_language1}}
{{=form.custom.widget.f_language2}} {{=form.custom.widget.f_language3}}
{{=form.custom.widget.f_language4}}
{{=form.custom.widget.f_language5}}</div></td>
<td width="34%"
class="formcell3">{{=form.errors.f_language1}}</td>
</tr>
<tr>
<td width="33%" class="formcell">Current Employer: </td>
<td width="33%" class="formcell2">
<div>{{=form.custom.widget.f_currentemployer}}</div></td>
<td width="34%"
class="formcell3">{{=form.errors.f_currentemployer}}</td>
</tr>
<tr>
<td width="33%" class="formcell">Last Employer: </td>
<td width="33%" class="formcell2">
<div>{{=form.custom.widget.f_lastemployer}}</div></td>
<td width="34%"
class="formcell3">{{=form.errors.f_lastemployer}}</td>
</tr>
<tr>
<td width="33%" class="formcell">Education Level: </td>
<td width="33%" class="formcell2">
<div>{{=form.custom.widget.f_educationlevel}}</div></td>
<td width="34%"
class="formcell3">{{=form.errors.f_educationlevel}}</td>
</tr>
<tr>
<td width="33%" class="formcell">Security Clearance: </td>
<td width="33%"
class="formcell2"><div>{{=form.custom.widget.f_securityclearance}}</div></td>
<td width="34%"
class="formcell3">{{=form.errors.f_securityclearance}}</td>
</tr>
<tr>
<td width="33%" class="formcell">Military Experience:
</td>
<td width="33%" class="formcell2">
<div>{{=form.custom.widget.f_militaryexperience}}</div></td>
<td width="34%"
class="formcell3">{{=form.errors.f_militaryexperience}}</td>
</tr>
<tr>
<td width="33%" class="formcell">Special Certications:
</td>
<td width="33%" class="formcell2">
{{=form.custom.widget.f_specialcertifications1}}
{{=form.custom.widget.f_specialcertifications2}}
{{=form.custom.widget.f_specialcertifications3}}
{{=form.custom.widget.f_specialcertifications4}}
{{=form.custom.widget.f_specialcertifications5}}
</td>
<td width="34%" class="formcell3"> </td>
</tr>
<tr>
<td width="33%" class="formcell"> </td>
<td width="33%"
class="formcell2">{{=form.custom.submit}}</td>
<td width="34%" class="formcell3"> </td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</center>
{{=form.custom.end}}
<https://lh4.googleusercontent.com/-AK9OXE0an3I/UrNn_EkEnmI/AAAAAAAAAMA/PzFQMtTsukM/s1600/none_error.jpg>
--
*This e-mail is confidential and may also be privileged. If you are not the
intended **recipient, please notify the sender immediately, delete it from
your system and do **not copy, disseminate, distribute or disclose any
information contained therein.*
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.