I have a simple form which I need the user to enter a postcode and that information then display on a specific template page.
My form looks like this:
// Directions Form
function DirectionsForm() {
// Create fields
$fields = new FieldSet(
new TextField('Postcode', 'Enter Postcode')
);
// Create actions
$actions = new FieldSet(
new FormAction('doDirections', 'Submit')
);
$form = new Form($this, 'DirectionsForm', $fields, $actions);
return $form;
}
function doDirections($data, $form) {
Session::set('StartPoint', $data->$postcode);
Director::redirect('get-directions/');
}
The template I wish to display my postcode on, then looks like this:
function Postcode() {
Session::get('StartPoint');
}
And finally, the action to display the value is:
<% control Postcode %>
<h2>My Postcode is: $data('StartPoint') </h2>
<% end_control %>
I know I'm missing something fundamentally basic here, but my brain has blanked - can anyone point me in the right direction please?