As I mentioned before, this:

form=FORM(INPUT(_name="id",_value=layer.id),INPUT
(_name="modified_on",_value=layer.modified_on),INPUT
(_name="name",_value=layer.name),INPUT
(_name="description",_value=layer.description),SELECT
(_name="type",_value=layer.type),SELECT
(_name="subtype",_value=subtype),INPUT
(_name="priority",_value=layer.priority),INPUT
(_name="enabled",_value=layer.enabled),INPUT(_type="submit",_value=T
("Save")))

has no knowledge of the database. form.accepts() will validate but
will perform no interaction with the database.

form_builder does not solve your problem and it is not what you want
since you have a custom html form.

you must do the insert manually after accept.

Massimo

On Dec 12, 2:49 pm, Fran <francisb...@googlemail.com> wrote:
> On Dec 12, 3:02 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > You are using a manual HTML form instead of {{=form}}. For an update
> > form you need to include
> > 1) <input type="hidden" name="id" value="{{=form.latest.id}}"
> > 2) {{=form.hidden_field()}}
>
> I had form.hidden.fields() but not form.latest.id, now corrected
> (form.record.id doesn't work for me).
> I also added the T2 field I need:
> <input type="hidden" name="modified_on__original"
> value="{{=form.latest.modified_on}}" />
>
> I also added id & modified_on to my FORM line:
> form=FORM(INPUT(_name="id",_value=layer.id),INPUT
> (_name="modified_on",_value=layer.modified_on),INPUT
> (_name="name",_value=layer.name),INPUT
> (_name="description",_value=layer.description),SELECT
> (_name="type",_value=layer.type),SELECT
> (_name="subtype",_value=subtype),INPUT
> (_name="priority",_value=layer.priority),INPUT
> (_name="enabled",_value=layer.enabled),INPUT(_type="submit",_value=T
> ("Save")))
>
> I also converted all my form fields from:
> <td><input name="name" type="text" value="{{=layer.name}}" /></td>
> to:
> <td><input name="name" type="text" value="{{=form.latest.name}}" /></
> td>
>
> Still nothing seem to link together the 'form' with the manual HTML :/
> What else is needed in this scenario?
>
> > Errors are in form.errors (it is a
> > dictionary). Because you are building the form manually, you need to
> > display the errors where you want them.
>
> I have a global error div underneath the form:
> {{if form.errors:}}<div class="error">{{=form.errors}}</div>{{pass}}
>
> I've added specific ones underneath each field (which I'll try to
> clean the output on later):
> {{if form.errors.name:}}<div class="error">{{=form.errors.name}}</div>
> {{pass}}
>
> None of these get triggered, though (although the global one did when
> using SQLFORM instead of FORM)
>
> > web2py does not build multi-table forms but you can create that
> > manually using form_builder or the way you are doing it:
> > > form=FORM(INPUT(_name="name"),INPUT(_name="description"),SELECT
> > > (_name="type"),SELECT(_name="subtype"),INPUT(_name="priority"),INPUT
> > > (_name="enabled"),INPUT(_type="submit",_value=T("Save")))
>
> So form_builder is something I only see described 
> here:http://groups.google.com/group/web2py/browse_thread/thread/582863bdd0...
> Doesn't seem to be part of the std code.
> I'll give it a try.
>
> > Notice that in the case below the form has no knowledge of the
> > database. This means accept will only do validation for you. No more.
>
> I'm not sure what 'no knowledge of the db means'
> The validation defined in the model is sufficient for validation,
> right? I don't need to redefine in my form? (unless I choose to add
> more restrictions)
>
> I try to do the db updates manually within 'if form.accepts', e.g.
> db(db['gis_layer_%s' % type_new].layer==t2.id).update
> (type=form.vars.subtype)
>
> But it doesn't work.
>
> I tried giving the form a matching name - within the HTML view, within
> the FORM & even in the form.accepts
> (as suggested 
> here:http://groups.google.com/group/web2py/browse_thread/thread/df59525001...)
>
> Nothing seems to work.
> My form values are kept, I get my 'Form accepted' message, but the DB
> remains stubbornly un-updated :/
--~--~---------~--~----~------------~-------~--~----~
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