what about?

form1=SQLFORM(somedb,_id="a")
if form1.accepts(request.vars,session,formname='a'):
    redirect(....)
form2=SQLFORM(somedb,_id="b")
if form2.accepts(request.vars,session,formname='b'):
    redirect(....)

Massimo


On Jun 24, 1:44 am, Trollkarlen <robbelibob...@gmail.com> wrote:
> Acually that wont work either because that dont change the _formname
> variable.
> Also all the internal fields and rows get the same names.
>
> I solved it with this fix(without the form_prefix set it should work
> as before):
> --- web2py.org/gluon/sqlhtml.py 2009-06-11 14:29:55.000000000 +0200
> +++ web2py/gluon/sqlhtml.py     2009-06-24 08:03:07.000000000 +0200
> @@ -385,6 +385,7 @@ class SQLFORM(FORM):
>          comments = True,
>          keepopts = [],
>          ignore_rw = False,
> +        form_prefix=None,
>          **attributes
>          ):
>          """
> @@ -425,6 +426,9 @@ class SQLFORM(FORM):
>                  record = records[0]
>              else:
>                  record = None
> +
> +        self.form_prefix = form_prefix or table._tablename
> +
>          self.record = record
>
>          self.record_id = None
> @@ -458,8 +462,7 @@ class SQLFORM(FORM):
>                  label = str(field.label) + ': '
>              self.custom.label[fieldname] = label
>
> -            field_id = '%s_%s' % (table._tablename, fieldname)
> -
> +            field_id = '%s_%s' % (self.form_prefix, fieldname)
>
>              label = LABEL(label, _for=field_id, _id='%s__%s' %
> (field_id, ID_LABEL_SUFFIX))
>
> @@ -508,7 +511,7 @@ class SQLFORM(FORM):
>              elif hasattr(field, 'widget') and field.widget:
>                  inp = field.widget(field, default)
>              elif field.type == 'upload':
> -                inp = self.widgets.upload.widget(field, default,
> upload)
> +                inp = self.widgets.upload.widget(field, default,
> upload, _id='%s' % (field_id))
>              elif field.type == 'boolean':
>                  inp = self.widgets.boolean.widget(field, default)
>                  if default:
> @@ -517,15 +520,15 @@ class SQLFORM(FORM):
>                      inpval = ''
>              elif OptionsWidget.has_options(field):
>                  if not field.requires.multiple:
> -                    inp = self.widgets.options.widget(field, default)
> +                    inp = self.widgets.options.widget(field, default,
> _id='%s' % (field_id))
>                  else:
> -                    inp = self.widgets.multiple.widget(field,
> default)
> +                    inp = self.widgets.multiple.widget(field,
> default, _id='%s' % (field_id))
>                  if fieldname in keepopts:
>                      inpval = TAG[''](*inp.components)
>              elif field.type == 'text':
> -                inp = self.widgets.text.widget(field, default)
> +                inp = self.widgets.text.widget(field, default,
> _id='%s' % (field_id))
>              elif field.type == 'password':
> -                inp = self.widgets.password.widget(field, default)
> +                inp = self.widgets.password.widget(field, default,
> _id='%s' % (field_id))
>                  if self.record:
>                      dspval = PasswordWidget.DEFAULT_PASSWORD_DISPLAY
>                  else:
> @@ -533,7 +536,7 @@ class SQLFORM(FORM):
>              elif field.type == 'blob':
>                  continue
>              else:
> -                inp = self.widgets.string.widget(field, default)
> +                inp = self.widgets.string.widget(field, default,
> _id='%s' % (field_id))
>
>              tr = self.trows[fieldname] = TR(label, inp, comment,
>                      _id=row_id)
>
> On Jun 23, 11:35 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > That is because you have two create form for the same table. Form
> > processing would not work either.
>
> > If the form where about different tables, the html "id" attributes
> > would be different.
> > If you need to customize them anyway, you can do one step lower level:
>
> > form1=SQLFORM(somedb,_id="....")
> > if form1.accepts(request.vars,session):
> >     redirect(....)
>
> > and same for form1.
>
> > Massimo
>
> > On Jun 23, 4:20 pm, Robert Marklund <robbelibob...@gmail.com> wrote:
>
> > > I have some problem with multiple create forms on the same page.
> > > def index():
> > >   form1 = crud.create(somedb)
> > >   form2 = crud.create(somedb)
> > >   return dict(form1=form1, form2=form2)
>
> > > The problem here is that all the rows and the inputs gets the same html id
> > > and thats not good for jQuery manipulation.
>
> > > I can see a solution in adding a form_prefix=None variable to SQLFORM that
> > > can fix all this.
>
> > > /R
>
> > > --
> > > ______________________________________________
> > > Robert Marklund
>
> > > Phone: +46 (0)46 19 36 82
> > > Mobile: +46 (0)70 213 22 76
> > > E-mail: robbelibob...@gmail.com
> > > ______________________________________________
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to