[web2py] Re: Simple ? How to remove Form Name (form :) from FORM Helper

2012-08-07 Thread Anthony
I assume that's not the complete code, as your function doesn't return 
anything. Does it end with something like:

return dict(form=form, ...)

And are you using a generic view (i.e., have you defined a contactus.html 
view)? If you use a generic view and pass a dictionary with more than one 
item to the generic view, you'll get a table with the dictionary keys in 
the first column and the values in the second. It looks like that's what 
you've got.

Anthony

On Tuesday, August 7, 2012 4:33:14 PM UTC-4, Rob_McC wrote:

 I'm sure it is easy, but I couldn't figure it out.

 *Q:*
 *How do you remove the*
 *form  :*
 *from the table generated with FORM() helper.*
 *
 *
 See red box on screen shot.

 *Reason*:
 I'm building a tutorial on how to do a simple Email form in web2py.

 Thanks!
 ~Rob

 def contactus():
 form=FORM(TABLE(TR(Your name:,INPUT(_type=text,_name=s_name,
 requires=IS_NOT_EMPTY())),
 TR(Your email:,INPUT(_type=text,_name=s_email,
 requires=IS_EMAIL())),
 TR(Subject:,INPUT(_type=text,_name=s_subject,
 requires=IS_NOT_EMPTY())),   
 TR(Message,TEXTAREA(_name=s_message, requires=
 IS_NOT_EMPTY())),
 TR(,INPUT(_type=submit,_value=SUBMIT



-- 





[web2py] Re: Simple ? How to remove Form Name (form :) from FORM Helper

2012-08-07 Thread Rob_McC
Thanks Anthony.

Yes, my function ends in
*RAM_Contact_Us/controllers/default.py*
with...

   return dict(form=form)  


*RAM_Contact_Us/views/default/contactus.html*
contains only this:
{{extend 'layout.html'}}
h3RAM_Contact_Form: Contact Us/h3


{{=BEAUTIFY(response._vars)}}


Here is entire Function - but I'm just starting to work with it.

def contactus():
form=FORM(TABLE(TR(Your name:,INPUT(_type=text,_name=s_name,
requires=IS_NOT_EMPTY())),
TR(Your email:,INPUT(_type=text,_name=s_email,
requires=IS_EMAIL())),
TR(Subject:,INPUT(_type=text,_name=s_subject,
requires=IS_NOT_EMPTY())),   
TR(Message,TEXTAREA(_name=s_message, requires=
IS_NOT_EMPTY())),
TR(,INPUT(_type=submit,_value=SUBMIT



if form.process().accepted:
response.flash = T('form accepted')
 
 #RAM_Contact_US
 #  ref: 
http://effbot.org/pyfaq/how-do-i-send-mail-from-a-python-script.htm   
 
FROM = 'Form submission www. - from %s' % form.vars.s_email
TO = [u...@example.com] # must be a list
 
SUBJECT = Hello!  --   + request.application


TEXT = This message was sent with Python's smtplib.


# Prepare actual message


message = \
From: %s
To: %s
Subject: %s


%s
 % (FROM, , .join(TO), SUBJECT, TEXT)

 # server.sendmail(FROM, TO, message)   

mail.send(to='mysgmail.com',
  subject=form.vars.s_subject,
  message=message,
  headers = {'Content-Type' : 'text/plain'}
  )
elif form.errors:
response.flash = T('form has errors')
return dict(form=form)  
 

-- 





[web2py] Re: Simple ? How to remove Form Name (form :) from FORM Helper

2012-08-07 Thread Rob_McC
My goal, is to have a simple email form that can be customized...

What I have is working, except for the 
form:
being displayed.

I wonder if there is a simpler way to create a email form.

Thanks
Rob 

-- 





Re: [web2py] Re: Simple ? How to remove Form Name (form :) from FORM Helper

2012-08-07 Thread Bruno Rocha
replace this:

{{=BEAUTIFY(response._vars)}}

with this:

{{=form}}

-- 





Re: [web2py] Re: Simple ? How to remove Form Name (form :) from FORM Helper

2012-08-07 Thread Rob_McC
rochacbruno:

*
*
Thanks!

It worked, and email is sent, and form:  is no longer there.

I'm going to to a working sample  - might be helpful to others.

Rob


{{extend 'layout.html'}}
h3RAM_Contact_Form: Contact Us/h3


{{=form}}


On Tuesday, August 7, 2012 6:30:01 PM UTC-4, rochacbruno wrote:

 replace this:

 {{=BEAUTIFY(response._vars)}}

 with this:

 {{=form}}


-- 





[web2py] Re: Simple ? How to remove Form Name (form :) from FORM Helper

2012-08-07 Thread Anthony


 {{extend 'layout.html'}}
 h3RAM_Contact_Form: Contact Us/h3


 {{=BEAUTIFY(response._vars)}}


OK, I guess you lifted the BEAUTIFY() line from the generic.load example. 
That helper is only used to beautify complex Python objects, like nested 
lists and dictionaries (see 
http://web2py.com/books/default/chapter/29/5#BEAUTIFY). It's used in the 
generic views in order to handle whatever might be returned by the 
function, but in a custom view, you generally wouldn't use it.

Anthony

--