Hi Chris,
I think Max just beat me in posting the solution. Thats the way I
implemented by custom forms. Have the controller send the form to the view
like
def controller():
return dict(form=form)
in your view just do
{{=form.custom.begin}}
#in between the opening and closing tags put in your normal html code and
make sure the element names corresponds to the column names as defined in
your database. web2py will handle the rest automatically. This is the most
flexible way while still making use of web2py's validators.
{{=form.custom.end}}
If you refuse to use web2py's css and js files, remember that
response.flash and session.flash wont work and also your validators also
wont work. so you would have to handle form validation yourself.
I hope this helps?
On Tuesday, July 3, 2012 9:18:44 PM UTC+1, Chris wrote:
>
>
> I've just started with web2py, so this might be obvious but I struggle to
> see how it works:
>
> I have a controller action which returns a form:
>
> def register():
> return dict(form=auth.register())
>
> I also have a view 'register.html' for this action, which is *
> self-contained* as it does NOT use any of the web2py frontend .css or .js
> stuff. All the HTML, CSS and JS are already done for the form too, e.g.
>
> ...
> <form method="post" class="h5form">
> <div class="own-labels">
> <label>First name<sup>*</sup></label>
> <input type="text" name="firstName" class="span3" placeholder="enter
> text…" required="required" tabindex="0">
> <label>Last name<sup>*</sup></label>
> <input type="text" name="lastName" class="span3" placeholder="enter
> text…" required="required" tabindex="1">
> <label>Email<sup>*</sup></label>
> <input type="email" name="email" class="span3" placeholder="enter
> text…" required="required" tabindex="3">
> </div>
> <div class="pull-left">
> <input type="submit" class="btn pull-right" style="margin-top:
> 15px;" value="Register">
> </div>
> </form>
> ...
>
> So now, how do I link the returned 'form' variables to the right fields in
> this pre-defined view? In the manual, it briefly mentions the use of
>
> {{=form.custom.begin}}
> ...
> {{=form.custom.end}}
>
> but it is not very clear to me how should I use it in my case. Is this
> only and right approach for implementing custom forms whose views are
> already fully defined in HTML, CSS and JS? Thank you.
>