Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
<?php class ContactPage extends Page { } class ContactPage_Controller extends Page_Controller { function Form() { $fields = new FieldSet( new TextField('Name'), new EmailField('Email', 'Email address') // Insert fields for the form here ); $actions = new FieldSet( new FormAction('doForm', 'Submit') ); $validator = new RequiredFields(array( 'Name', 'Email' // Specify fields here )); return new Form($this, 'Form', $fields, $actions, $validator); } function doForm($data, $form) { $email = new ContactPage_Email( // Create ContactPage_Email.ss in mysite/templates/email $data['Email'], // The from address 'admin@somewhere.com', // The to address 'The contact page has been submitted' // Subject ); $email->populateTemplate(array( 'FormData' => new ArrayData($data) )); $email->send(); } } class ContactPage_Email extends Email_Template { protected $ss_template = 'ContactPage_Email'; } ?>
This paste will be private.
From the Design Piracy series on my blog: