I cannot think of a better way. Nice site by the way. I would only
replace
<div class="hidden">
{{=form.hidden_fields()}}
</div>
</form>
with
{{=form.custom.end}}
On Jan 2, 1:15 pm, "K.R.Arun" <[email protected]> wrote:
> hi,
> I'm new to web2py and my first experience with it is fun.
> It's true that I can develop fast but for now customization is pain in
> some places.
> For example, I like css over tables. And I have to add some fieldsets
> to my form.
> Form is generated from a table and using SQLForm(because many tasks
> are done by it, like automatic insertion, validation etc.,)
>
> You can see my site on-line athttp://exodus-fest.appspot.com/
> (It uses css3, best viewed on a latest chrome/firefox or any other
> css3 supported browser)
>
> at the end of the post I'm posting code for view and controller.
> Now tell me is there any better way to do the same; like using
> SQLFORM.factory (I tried, but hopelessly failed.) so that view get
> shortened.
>
> Now, what follows is my code...
>
> controller
> ~~~~~~~
>
> def register():
> msg = ''
> fieldLabels={'name':'Full Name:', 'course':'Enrolled Course:',
> 'college':'College/University:', 'mobile':'Mobile Number:',
> 'email':'Email Address:'}
> form = SQLFORM(db.register, submit_button='Register',
> labels=fieldLabels)
> if form.accepts(request.vars, session):
> form = None
> a = q = c = d = ''
> import smtplib
> toaddr = request.vars.email
> q = 'Yes' if request.vars.quiz else 'No'
> a = 'Yes' if request.vars.animation else 'No'
> c = 'Yes' if request.vars.coding else 'No'
> d = 'Yes' if request.vars.dance else 'No'
> body = ('Dear ' + request.vars.name +',\n\n' +
> 'It is a pleasure for me to let you know that you had
> successfully
> registered for the Exodus-10 (Cultural and IT fest) ' +
> 'conducted by Computer Science Dept. of St. Thomas College,
> Thrissur
> \n\n'+
> 'You are registered to:\n'+
> ' Quiz : ' + q + '\n' +
> 'Animation : ' + a + '\n' +
> ' Coding : ' + c + '\n' +
> ' Dance : ' + d + '\n\n'+
> 'Please note that program commence on 14th Jan, 2010, 9:30am'+
> '\n\n\nThank You,\nShibu \n(Student Co-ordinator)\nMobile :
> +919496349988' + '\n Website:http://exodus-fest.appspot.com/')
>
> mail.send(to = toaddr, subject='Exodus: Event registration',
> message= body)
> msg += "You are Successfully registered. Please Check your
> email."
> elif form.errors:
> if form.errors.name: form.errors.name='Your name seems too
> short'
> if form.errors.college: form.errors.college='It is a too
> short name'
> if form.errors.mobile: form.errors.mobile='Enter a valied
> Mobile
> Number'
> if form.errors.email: form.errors.email='Enter a valied Email
> Address'
> return dict(form=form, msg=msg)
>
> --------------------------------------------------------------------------------------------------------------------------------------------
> now view
> ~~~~~~~
>
> {{extend 'tmpl.html'}}
>
> {{if form:}}
> {{lbl=form.custom.label}}
> {{wdgt=form.custom.widget}}
>
> <form action="" enctype="multipart/form-data" method="post">
> <h1>Exodus: Event Registration Form</h1>
> <fieldset>
> <legend>Your Details</legend>
> <ul>
> <li>
> <label for="register_name"
> id="register_name__label">{{=lbl.name}}
> </label>
> {{=wdgt.name}}
> </li>
> <li>
> <label for="register_course"
> id="register_course__label">
> {{=lbl.course}}</label>
> {{=wdgt.course}}
> </li>
> <li>
> <label for="register_college"
> id="register_college__label">
> {{=lbl.college}}</label>
> {{=wdgt.college}}
> </li>
> </ul>
> </fieldset>
> <fieldset>
> <legend>Contact Information</legend>
> <ul>
> <li>
> <label for="register_mobile"
> id="register_mobile__label">
> {{=lbl.mobile}}</label>
> {{=wdgt.mobile}}
> </li>
> <li>
> <label for="register_email"
> id="register_email__label">
> {{=lbl.email}}</label>
> {{=wdgt.email}}
> </li>
> </ul>
> </fieldset>
> <fieldset>
> <legend>Participating Events</legend>
> <div class="events">
> <ul>
> <div><li>
> <label for="register_quiz"
> id="register_quiz__label">{{=lbl.quiz}}
> </label>
> {{=wdgt.quiz}}
> </li>
> <li>
> <label for="register_animation"
> id="register_animation__label">
> {{=lbl.animation}}</label>
> {{=wdgt.animation}}
> </li></div>
> <div><li>
> <label for="register_coding"
> id="register_coding__label">
> {{=lbl.coding}}</label>
> {{=wdgt.coding}}
> </li>
> <li>
> <label for="register_dance"
> id="register_dance__label">
> {{=lbl.dance}}</label>
> {{=wdgt.dance}}
> </li></div>
> </ul>
> </div>
> </fieldset>
> <input type="reset" value="Reset" />
> <input type="submit" value="Register" />
> <div class="hidden">
> {{=form.hidden_fields()}}
> </div>
> </form>
>
> {{pass}}
>
> {{=msg}}
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.