Using your example Massimo:
db.define_table('person',SQLField('name'))
def index():
form=SQLFORM(db.person)
if form.accepts(request.vars,session)
return dict(form=form)
{{if form.errors:}}{{=form.errors}}{{pass}}
<form>
<input type="text" name='name' value="{{=
form.values.name}}" />
<input type="submit" />
{{=form.hidden_fields()}} <!--you need this to prevent double
submission and allow multiple forms //-->
</form>
Could i do:
<form>
{{if form.errors.name:}}<div
class="error">{{=
form.errors.name}}<div>{{pass}}
<input type="text" name='name' value="{{=
form.values.name}}" />
<input type="submit" />
{{=form.hidden_fields()}} <!--you need this to prevent double
submission and allow multiple forms //-->
</form>
So I could put the errors next to the field instead of all to together
at the top, I know you said you could on your second post but then you
said you were changing it, so I wanted to know if you still can. I've
already written a helper for this but if it's now built In I will use
that :)
On Nov 10, 6:54 am, DenesL <
denes1...@yahoo.ca> wrote:
> I will have to go over the changes in html.py but:
> 1) I also agree with Bill. The point here was really the MVC
> separation as he calls it in a separate post. Plus a leaner version of
> the generated HTML. I have no idea how hard would it be to re-position
> a TD in a complex form just using CSS.
> 2) Many debatable positions can be taken here too. Should labels be
> considered part of the form data or not? Where would they fit better?
> <add your own here >
> I know the info is available from other sources but I think it is more
> elegant to have it all come from one source: the form itself.
> 2b) A separate issue here is the use of display only fields versus the
> current all input. The presentation value becomes dependent on its
> final use (input or display), and the existence of: record, reference,
> requires and widgets for each. Again, the objective would be to have
> it all available from one source: the form.
> 3) Errors have been always available from the form object, the way it
> should be IMO. Here I want to hear about other nice and elegant ways
> to handle the errors. Maybe we can have one in the improved version if
> the opinions are not too divergent.
> 4) I have cascades and autocompletes in my currentformsand I posted
> how I did it, but the setup is a little convoluted so I would like to
> automate it. They use jQuery plugins. Other special field types that
> can be added here? Maybe make them into web2py plugins?.
> It is all a work in progress...
>
> On Nov 10, 2:01 am, mdipierro <
mdipie...@cs.depaul.edu> wrote:
>
> > Attention!!! I posted in trunk a complete rewrite of gluon/html.py
>
> > In my tests it does not break anything but please try it and let me
> > know if it break something before I post an new web2py version.
>
> > The reason for the rewrite is mainly to make form processing twice as
> > fast and the code more readable, but also to include Bill's patch in a
> > more elegant way. The new html is 5% smaller than the previous one.
>
> > About the comments below:
>
> > 1) I agree with Bill
> > 2) one can do db.table[fieldname].label and get the label (*)
> > 3) I agree. One can do {{if form.errors.has_key(fieldname):}}
> > {{=form.errors[fieldname}}{{pass}} (*)
> > 4) Now you can do acustomform like
>
> > db.define_table('person',SQLField('name'))
>
> > def index():
> > form=SQLFORM(db.person)
> > if form.accepts(request.vars,session)
> > return dict(form=form)
>
> > {{if form.errors:}}{{=form.errors}}{{pass}}
> > <form>
> > <input type="text" name='name' value="{{=
form.values.name}}" />
> > <input type="submit" />
> > {{=form.hidden_fields()}} <!--you need this to prevent double
> > submission and allow multipleforms//-->
> > </form>
>
> > Please let me know if it works. I am hoping to post a new release
> > before my talk at pyworks2008.
>
> > Massimo
>
> > On Nov 10, 12:06 am, billf <
billferr...@blueyonder.co.uk> wrote:
>
> > > 1) tables over something else: it does seem to be a subject of great
> > > discussion that people get very energised about. But I guess that if
> > > you take out tables then someone else will object :-) Isn't the idea
> > > ofcustomformsthat if you want labels you code your own view?
>
> > > 2) labels: personally I don't think the specification of labels fits
> > > elegantly in the model or the controller but I recognise the need to
> > > put them somewhere if you want to avoid duplicating them in multiple
> > > views. Ideally, they could be defined in an application view, e.g.
> > > layout.html, and referenced by views that extend that - is that
> > > possible? I would interested to hear other people's views.
>
> > > 3) I thinkcustomerror handling is part ofcustomviews: the
> > > > > 3)Customformsalso needcustomform error handling. My solution so