Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Forum Module /

Discuss the Forum Module.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Getting error on form


Go to End


4 Posts   2375 Views

Avatar
robskinn

Community Member, 12 Posts

14 May 2015 at 9:00am

Hi,
I'm re-using an old form from the SilverStripe tutorial in the latest version (3.1) but am getting an intermittent error.

[User Deprecated] SSTemplateParser->ClosedBlock_Handle_Control is deprecated. is deprecated. Use or instead. Called from SSTemplateParser->ClosedBlock__finalise.

This is the code that I'm using. Any ideas?

<?php
class ContactPage extends Page {
}

class ContactPage_Controller extends Page_Controller {
    public static $allowed_actions = array('Form');
    
    public function Form() { 
        $fields = new FieldList( 
            new TextField('Name'), 
            new EmailField('Email'), 
            new TextareaField('Message')
        ); 
        
        $actions = new FieldList( 
            new FormAction('submit', 'Submit') 
        ); 
        
        $validator = new RequiredFields('Name', 'Email', 'Message');
        return new Form($this, 'Form', $fields, $actions, $validator);         
    }
    
    public function submit($data, $form) { 
        $email = new Email(); 

        $email->setTo('email@address.co.uk'); 
        $email->setFrom($data['Email']); 
        $email->setSubject("Contact Message from {$data["Name"]}"); 

        $messageBody = " 
            <p><strong>Name:</strong> {$data['Name']}</p> 
            <p><strong>Message:</strong> {$data['Message']}</p> 
        "; 
        $email->setBody($messageBody); 
        $email->send(); 
        
        return array(
            'Content' => '<p>Thank you for your feedback.</p>',
            'Form' => '<p>Thank you for your feedback.</p>'
        );
    }
}











Avatar
helenclarko

Community Member, 166 Posts

14 May 2015 at 9:04am

Edited: 14/05/2015 9:04am

Hi Robskinn,

I believe the tutorial you were using was out of date.
Do you have the .ss file to look at too?

I think you will find that the .ss file is using <% control %> rather than <% loop %>.

-helenclarko

Avatar
robskinn

Community Member, 12 Posts

14 May 2015 at 9:52am

Edited: 14/05/2015 10:02am

Yes, I think you may be right -This is what I have in my ss file

<div>
    <% control getForm %>
    $Form
    <% end_control %>
</div>

Just tested 'loop' and so far it's looking good - many thanks

<div>
    <% loop getForm %>
    $Form
    <% end_loop %>
</div>

Avatar
Pyromanik

Community Member, 419 Posts

25 May 2015 at 3:01am

Judging purely by the variable names used, you probably want <% with ... %> rather than <% loop ... %>