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 ContactForm extends Form { function __construct($controller, $name) { $fields = new FieldSet( new TextField('Name', '', 'Name'), new EmailField('Email', '', 'E-mail'), new NumericField('Phone', '', 'Telephone'), new TextareaField('Message', '', '5', '35', 'Description') ); $actions = new FieldSet( new FormAction('doForm', 'Contact') ); $validator = new RequiredFields(array( 'Name', 'Email', 'Message' )); 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'], 'removed', 'some subject' ); $email->populateTemplate(array( 'FormData' => new ArrayData($data) )); $email->send(); Director::redirect('/submission-received/'); } } class ContactPage_Controller extends Page_Controller { function Form() { return new ContactForm($this, 'Form'); } } class ContactPage_Email extends Email_Template { protected $ss_template = 'ContactPage_Email'; } ?>
This paste will be private.
From the Design Piracy series on my blog: