Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
<?php class MyForm extends Form { function __construct($controller, $name) { $fields = new FieldSet( new TextField('Name', 'Your name'), new EmailField('Email', 'Email address') ); $actions = new FieldSet( new FormAction('doForm', 'Submit') ); $validator = new RequiredFields(array( 'Name', 'Email' )); parent::__construct($controller, $name, $fields, $actions, $validator); } function forTemplate() { return $this->renderWith(array( $this->class, 'Form' )); } function doForm($data, $form) { $email = new ContactPage_Email( $data['Email'], 'admin@somewhere.com', 'The contact page has been submitted' ); $email->populateTemplate(array( 'FormData' => new ArrayData($data) )); $email->send(); Director::redirect('finished-page'); // Redirect to the page with the URLSegment 'finished-page' } } ?>
This paste will be private.
From the Design Piracy series on my blog: