17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2158 Views |
-
Accessing Custom Form Variables

12 November 2007 at 3:07pm Last edited: 12 November 2007 3:08pm
Howdy
I've got the following code for my custom form but it is just sending an empty e-mail;
<?php
class EmailForm_Controller extends Page_Controller {function SignupForm() {
return new Form($this, "SignupForm", new FieldSet(
// List the your fields here
new TextField("FirstName", "First name"),
new TextField("Surname"),
new EmailField("Email", "Email address")), new FieldSet(
// List the action buttons here
new FormAction("doform", "Sign up")), new RequiredFields(
// List the required fields here: "Email", "FirstName"
));
}function doform($data, $form) {
mail("james@gooduse.co.nz", "Comments", $form->$FirstName);// Redirect to a page thanking people for registering
Director::redirect('thanks-for-registering/');
}}
?>At the moment you'll see I'm using $form->$FirstName as a test for the e-mail field but it's not working - what syntax should I be using?
Cheers
James
-
Re: Accessing Custom Form Variables

12 November 2007 at 3:18pm Last edited: 12 November 2007 3:19pm
You can use either of the following:
$data['FirstName'] // $data is an array containing the form names and values
// OR
$form->dataFieldByName('FirstName')->Value() // This is the form object, getting the FirstName form object, then getting that object's value. -
Re: Accessing Custom Form Variables

12 November 2007 at 3:44pm
Hey, it's Kelle Brickhead! (just look at her avatar)
| 2158 Views | ||
|
Page:
1
|
Go to Top |


