*sigh*
On Fri, Nov 21, 2008 at 11:02 AM, Wes James <[EMAIL PROTECTED]> wrote:
>
> oh, i forgot, i can hide with css....
>
> i'm going to try that.
>
> On Fri, Nov 21, 2008 at 10:00 AM, Wes James <[EMAIL PROTECTED]> wrote:
> > Yarko,
> >
> > so far, i can get it to work if the checkbox fields are not hidden on
> > the form. My problem now is trying to make 'hidden' checkbox form
> > elements. I don't see any way to hide checkbox elements.
> >
> > On Fri, Nov 21, 2008 at 9:39 AM, Yarko Tymciurak <[EMAIL PROTECTED]>
> wrote:
> >> Wes -
> >>
> >> I think we need a complete - if minimized example which others can use
> to
> >> reproduce. Can you provide?
> >>
> >> Thanks,
> >> Yarko
> >>
> >> On Fri, Nov 21, 2008 at 10:15 AM, mdipierro <[EMAIL PROTECTED]>
> wrote:
> >>>
> >>> SQLFORM(...,fields=[...])
> >>>
> >>> should be used to determine which fields are expected and which should
> >>> be ignored.
> >>>
> >>> For T2 use
> >>>
> >>> db.table.exposes=[....] # list of field names
> >>>
> >>> Massimo
> >>>
> >>> On Nov 21, 9:52 am, billf <[EMAIL PROTECTED]> wrote:
> >>> > Massimo
> >>> >
> >>> > I think there is a typo in your point 1) and it should read "update
> >>> > form and it was *checked* in the original record". The behaviour of
> >>> > the setting the checkbox value is not in question.
> >>> >
> >>> > I believe the problem Wes originally raised is that a boolean field
> on
> >>> > the database gets set to False erroneously if a form does not contain
> >>> > a control for that field (either hidden or a checkbox). This is
> >>> > because web2py (any server-side code) cannot distinguish between an
> >>> > unchecked checkbox and an absence of a checkbox. So the missing
> >>> > control is interpreted as unchecked/false and stored as such. This
> >>> > differs from other field types where a missing control can and is
> >>> > interpreted as "no change".
> >>> >
> >>> > On Nov 21, 3:28 pm, mdipierro <[EMAIL PROTECTED]> wrote:
> >>> >
> >>> > > It was mentioned in one of the previous emails. I am not sure it
> helps
> >>> > > with the current problem. I am not sure I understand the current
> >>> > > problem.
> >>> >
> >>> > > checkboxes are always unchecked unless:
> >>> > > 1) update form and it was unchecked in the original record
> >>> > > 2) create form and corresponding field has default=True
> >>> >
> >>> > > Are you saying this is not the case or that I am missing something?
> >>> > > I think this is the correct behavior
> >>> >
> >>> > > Massimo
> >>> >
> >>> > > On Nov 21, 8:49 am, billf <[EMAIL PROTECTED]> wrote:
> >>> >
> >>> > > > Massimo
> >>> >
> >>> > > > In what way are you suggesting "SQLFORM and and FORM take a
> >>> > > > parameter
> >>> > > > hidden=dict(key='value')" would be used?
> >>> >
> >>> > > > Bill
> >>> >
> >>> > > > On Nov 21, 2:10 pm, mdipierro <[EMAIL PROTECTED]> wrote:
> >>> >
> >>> > > > > Do you have default=False in the database?
> >>> >
> >>> > > > > SQLFORM and and FORM take a parameter hidden=dict(key='value')
> >>> >
> >>> > > > > Massimo
> >>> >
> >>> > > > > On Nov 21, 6:32 am, billf <[EMAIL PROTECTED]>
> wrote:
> >>> >
> >>> > > > > > I am investigating a possible solution to the above problem
> that
> >>> > > > > > would
> >>> > > > > > return fieldname=OFF if a displayed checkbox is unchecked.
> >>> >
> >>> > > > > > This would enable web2py to retain existing values for a
> boolean
> >>> > > > > > field
> >>> > > > > > if a request.var was not present.
> >>> >
> >>> > > > > > However, I recognise that some people may consider returning
> >>> > > > > > fieldname=OFF a contravention of protocol - does anyone feel
> >>> > > > > > like
> >>> > > > > > that?
> >>> >
> >>> > > > > > FYI the solution is to add a hidden "off" checkbox
> (value='off')
> >>> > > > > > for
> >>> > > > > > each displayed checkbox (both with the same name) and when
> the
> >>> > > > > > normal
> >>> > > > > > checkbox is clicked setting the "off checkbox appropriately
> so
> >>> > > > > > that
> >>> > > > > > whatever the status of the normal checkbox either name=on or
> >>> > > > > > name=off
> >>> > > > > > will be returned.
> >>> >
> >>> > > > > > Any thoughts gratefully received.
> >>> >
> >>> > > > > > On Nov 21, 8:13 am, billf <[EMAIL PROTECTED]>
> wrote:
> >>> >
> >>> > > > > > > If the following explanation is correct it is a big
> >>> > > > > > > coincidence
> >>> > > > > > > because I have just been looking at this behaviour.
> >>> >
> >>> > > > > > > When a form is submitted, if there is no parameter for a
> field
> >>> > > > > > > then
> >>> > > > > > > one of 2 things happen (simplified):
> >>> >
> >>> > > > > > > If it is NOT a checkable form control (checkable=check box
> or
> >>> > > > > > > radio
> >>> > > > > > > button) then the original form value is used. In the case
> of
> >>> > > > > > > an
> >>> > > > > > > existing record, this will be the value in the existing
> >>> > > > > > > record. In the
> >>> > > > > > > case of a new record then any defailt will be used.
> >>> >
> >>> > > > > > > If it IS a checkable form control then it is impossible to
> >>> > > > > > > distinguish
> >>> > > > > > > between a missing parameter and an unchecked control
> because
> >>> > > > > > > CGI
> >>> > > > > > > doesn't send "mycheckbox=off" - it just doesn't send
> anything.
> >>> > > > > > > So to
> >>> > > > > > > be able to set a boolean field to false, web2py must say
> >>> > > > > > > missing==unchecked.
> >>> >
> >>> > > > > > > In your case, you set checkboxes on page2 and everything is
> >>> > > > > > > fine.
> >>> > > > > > > When you amend page 1 and submit, no checkboxes are present
> so
> >>> > > > > > > web2py
> >>> > > > > > > sets the associated fields to False. You go back to page 2
> >>> > > > > > > and, lo and
> >>> > > > > > > behold, all the checkboxes are unchecked.
> >>> >
> >>> > > > > > > The only solution, given the current setup, is that any
> fields
> >>> > > > > > > represented as checkable controls but not displayed in the
> >>> > > > > > > current
> >>> > > > > > > form must be set up in the form as "hidden" so that checked
> >>> > > > > > > fields are
> >>> > > > > > > returned even if they are not displayed.
> >>> >
> >>> > > > > > > I think it should be possible to create the "hidden" fields
> >>> > > > > > > automatically in SQLFORM/FORM, although supporting "custom
> >>> > > > > > > forms" (where a developer may not include a field that the
> >>> > > > > > > standard
> >>> > > > > > > SQLFORM would include) could be a complication.
> >>> >
> >>> > > > > > > On Nov 21, 6:20 am, "Wes James" <[EMAIL PROTECTED]>
> wrote:
> >>> >
> >>> > > > > > > > I have an app that on one page I have a set of fields
> (first
> >>> > > > > > > > 20 fields
> >>> > > > > > > > of say 50) I have manually placed. All saves well and
> when
> >>> > > > > > > > I go to
> >>> > > > > > > > another page and come back all is well.
> >>> >
> >>> > > > > > > > On a separate page, I edit the rest of these fields.
> Part
> >>> > > > > > > > of these
> >>> > > > > > > > are check box fields and some others including textarea
> >>> > > > > > > > fields.
> >>> >
> >>> > > > > > > > When I save the data on this page - all is well.
> >>> >
> >>> > > > > > > > I then go back to the first page and make a change and
> save
> >>> > > > > > > > the data -
> >>> > > > > > > > fine, but if I go back to the page with the check boxes,
> >>> > > > > > > > they are all
> >>> > > > > > > > cleared out - I look in the DB in admin area and yes,
> they
> >>> > > > > > > > are all set
> >>> > > > > > > > to False. But the textarea fields do not do this on this
> >>> > > > > > > > page - they
> >>> > > > > > > > keep their data just fine.
> >>> >
> >>> > > > > > > > So I created a test page and made a controller like I
> >>> > > > > > > > already have:
> >>> >
> >>> > > > > > > > form=t2.create(db.student)
> >>> > > > > > > > return dict(form=form)
> >>> >
> >>> > > > > > > > and then in a test.html do {{=form}
> >>> >
> >>> > > > > > > > I then save the page with a check box selected - fine -
> that
> >>> > > > > > > > works.
> >>> >
> >>> > > > > > > > I then go back to my first page and make a change and
> save.
> >>> > > > > > > > Go back
> >>> > > > > > > > to the test page and the check box is cleared.
> >>> >
> >>> > > > > > > > Why is it doing this?
> >>> >
> >>> > > > > > > > thx,
> >>> >
> >>> > > > > > > > -wj
> >>>
> >>
> >>
> >> >>
> >>
> >
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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
-~----------~----~----~----~------~----~------~--~---