Forum OpenACS Q&A: Question about ad_form

Collapse
Posted by Richard Hamilton on
I have just written my first form(!!) using ad_form.

Very satisfying to be able to do so much with so little code.

I was wondering how to format my form. That is to say, I have some text fields with a textarea for a short message to be typed. The default size of the textarea box is a bit on the small side and I would like to make it bigger.

Thanks
Richard

Collapse
2: Re: Question about ad_form (response to 1)
Posted by Richard Hamilton on
Also I would be very grateful if someone would explain why my variables are null, i.e. nothing entered in the form gets appended to the email message. Do I need to use uplevel or something, or maybe a different declarative notation? (Sorry about the duplicate posting).
ad_form -name brochure -form {
	{first_name:text {label "First Name"}}
	{last_name:text {label "Last Name"}}
	{address_1:text {label "Address Line One"}}
	{address_2:text,optional {label "Address Line Two"}}
	{address_3:text,optional {label "Address Line Three"}}
	{address_4:text,optional {label "Address Line Four"}}
	{town:text {label "Town"}}
	{county:text {label "County"}}
	{country:text,optional {label "Country"}}
	{telephone:text,optional {label "Telephone Number"}}
	{message:text(textarea),optional {label "Brief Message"}}
} -on_submit {

set subject "Brochure request from Servername"

set message_body "Please would you send me a brochure

My address is:

"

append $message_body $first_name "\n" $last_name "\n" $address_1" \n" $address_2 "\n" $address_3 "\n" $address_4 "\n" $town "\n" $county "\n" $country "\nTelephone: " $telephone "\n\nMessage text: " $message

if { [catch {ns_sendmail "ricky.hamilton@btopenworld.com" "admin@servername.co.uk" $subject $message_body} errmsg] } {
	ns_log Warning "Error sending brochure request email - $errmsg" }
}
I'm just trying to work this through as a simple example.

Thanks in advance
R.