[Zope] Re: boolean help

2000-12-12 Thread Robin . Lamb

On Sun, 10 December 2000, Martijn Pieters wrote:

 
  I am new at programming and have been unable to code a boolean button
  into my Zope Portal registgration form that can recall the previous
  selection such that it can be de-selected.  Basically, I want to enable
  a user on my site to sign-up, flip a boolean on, log out, then later log
  back in and unflip that boolean.  It's the "unflip" that catches me.  I
  have been able to make the boolean reflect the fact that it is selected
  when the user logs back on, back I can't make it unselectable.  Here's
  the code I've got now that doesn't allow for de-selecting,
 
  input type="checkbox" name="current_college_student"
dtml-if" member.current_college_student" 
  checked
/dtml-if
 value="member.current_college_student"
  bCurrent College Student/b
  
  I guess I need to tell the database that if no value is entered, it
  should delete "member.current_college_student" from its records.  
 
 I am not sure what your problem is here. 
 
 Are you talking about the fact that if the checkbox isn't checked, that
 the browser doesn't send *any* information about the field
 'current_college_student'?
 
 If so, you can check for it's absense with the DTML construct 'dtml-unless
 current_college_student .. /dtml-unless. Or you could add a hidden form
 field *before* the checkbox which defines a default, empty value, like so:
 
   input type="hidden" name="current_college_student:default" value=""
 
 You can of course put any other value in there. The browser will always
 pass this back to Zope, and then you can test for the value of
 current_college_student.
 
 Hope this helps!!


That doesn't quite do it.  Someone joins the network and is taken to a mandatory form 
where they fill in eight pages of information about themself.  They submit the 
information.  Everything's cool up to this point.  

A year later, they graduate from school and become a farmer.  They still want to be a 
member of the network.  They log back in, re-access their form information, deselect 
the checkbox for "student" and select the "professional" checkbox.  I can't get my 
zportal ZODB to recognize the deselection.  You'll notice in the code above that when 
the box is checked and submitted, the value "member._" is submitted to the 
database.  To display a checked box when the page is re-loaded, I use dtml-if 
"member.__"checked/dtml-if within the inpupt type=boolean... tag.  

Now, I want to tell the database that if a form page is re-submitted and a boolean box 
that was checked is no longer checked, it's previous value should be deleted from that 
user's record.  

Can anybody shed any light on the matter?  

Robin Lamb

811 Oak St.
San Francisco, CA
94117
-USA-
phone: 415.241.0441
--
[EMAIL PROTECTED] is brought to you by 
the Stanford Alumni Association and Critical Path.

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




[Zope] Re: boolean help

2000-12-10 Thread Martijn Pieters

On Sat, Dec 09, 2000 at 01:29:41PM -0800, [EMAIL PROTECTED] wrote:
 I hope you don't think this email innappropriate, but you were so kind
 in responding to a previous question that I posted on the zope mailing
 list that I thought I would direct this simple question to you alone.  

It flatters me that you think I may be able to answer your qeustions :)
But I would appreciate it if you do keep sending your questions to the
mailinglists instead of directly to me. If only so that other people can
benefit from any answers you get!

I have added the Zope list to recipients of this reply.

 I am new at programming and have been unable to code a boolean button
 into my Zope Portal registgration form that can recall the previous
 selection such that it can be de-selected.  Basically, I want to enable
 a user on my site to sign-up, flip a boolean on, log out, then later log
 back in and unflip that boolean.  It's the "unflip" that catches me.  I
 have been able to make the boolean reflect the fact that it is selected
 when the user logs back on, back I can't make it unselectable.  Here's
 the code I've got now that doesn't allow for de-selecting,

 input type="checkbox" name="current_college_student"
   dtml-if" member.current_college_student" 
 checked
   /dtml-if
value="member.current_college_student"
 bCurrent College Student/b
 
 I guess I need to tell the database that if no value is entered, it
 should delete "member.current_college_student" from its records.  

I am not sure what your problem is here. 

Are you talking about the fact that if the checkbox isn't checked, that
the browser doesn't send *any* information about the field
'current_college_student'?

If so, you can check for it's absense with the DTML construct 'dtml-unless
current_college_student .. /dtml-unless. Or you could add a hidden form
field *before* the checkbox which defines a default, empty value, like so:

  input type="hidden" name="current_college_student:default" value=""

You can of course put any other value in there. The browser will always
pass this back to Zope, and then you can test for the value of
current_college_student.

Hope this helps!

 It seems so simple, I'm almost embarrassed to post my question to the
 general zope mailing list.  

Well, it wasn't so simple that you could figure it out on your own. There
may be other people that struggle with this, and they would benefit from
your questions and the answers you may receive.

-- 
Martijn Pieters
| Software Engineer  mailto:[EMAIL PROTECTED]
| Digital Creations  http://www.digicool.com/
| Creators of Zope   http://www.zope.org/
-

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )