3212 Posts in 847 Topics by 809 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 192 Views |
-
[SOLVED] custom template issues SS.30

20 February 2013 at 3:43am
Hi there,
I'm currently trying to add a form with a simple email field into the header include of my theme so I can populate the newsletter module from any page with a "Newsletter sign up" feature.
I can get the form to display and function if I have it directly in my Page.php but now I'm trying to break it out and use it as a form extension like so:
newslettersignup
- code
- NewsletterForm.php
- templates
- Includes
- NewsletterForm.ss
_config.phpI'm not exactly sure why but it doesn't seem to render with it's own template, here is my code:
NewsletterForm.php
<?php
class NewsletterForm extends Form{
public function __construct($controller, $name) {
public function NewsletterFormData(){
$fields = new FieldList(
new EmailField("Email", "Sign up to our news letter", "your email address")
);if(Session::get('PageTypeWatcher') == 'SubscriptionPage'){
$actions = new FieldList(
new FormAction("NewsletterForm", "»")
);
} else {
$actions = new FieldList(
new FormAction("PassNewsletterForm", "»")
);
}$required = new RequiredFields("Email");
parent::__construct($controller, $name, $fields, $actions, $required);
}public function forTemplate() {
return $this->renderWith(array($this->class, 'Form'));
}public function PassNewsletterForm($data, $form) {
if($data['Email']){
Session::set('Email', $data['Email']);
return $this->redirect(Director::baseURL() . 'newsletter');
}
}public function NewsletterForm($data, $form) {
if($data['Email']){
Session::set('Email', $data['Email']);
return $this->redirect(Director::baseURL() . $this->URLSegment . '/?return');
}
}
}
}?>
NewsletterForm.ss
<form $FormAttributes>
<fieldset>
<% loop Fields %>
$FieldHolder
<% end_loop %>
<% loop Actions %>
$Field
<% end_loop %>
</fieldset>
</form>Any ideas?
Many thanks
| 192 Views | ||
|
Page:
1
|
Go to Top |

