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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Action 'LoyaltyForm' isn't allowed on class StandardPage_Controller


Go to End


6 Posts   1907 Views

Avatar
Sly

Community Member, 4 Posts

16 August 2014 at 3:26am

Hi, I am new to SilverStripe and have just migrated a SilverStripe website to my hosting for a client from files and DB supplied from previous hosts.

The site seems to be running ok on the test server, but when filling out the 'newsletter signup' form I get taken to a white page with the message: "Action 'LoyaltyForm' isn't allowed on class StandardPage_Controller"

The form is on this page: http://ewo.developmentandtesting.co.uk/management-consultancy/

Can anyone help with how to fix this please?

Many thanks.

Avatar
martimiz

Forum Moderator, 1391 Posts

16 August 2014 at 3:38am

Edited: 16/08/2014 3:40am

Try adding LoyaltyForm to the $allowed_actions array in the StandardPage_Controller class. If the array is not there, just add it:

class StandardPage_Controller extends .... {

		private static $allowed_actions = array(
				'LoyaltyForm'
		);

Avatar
Sly

Community Member, 4 Posts

16 August 2014 at 3:43am

Thank you for your reply.

Could you help me with where to put it please? Here is the code for mysite/code/StandardPage_Controller.php

<?php
/**
 * Defines the HomePage page type
 */
 
class StandardPage extends Page {
   static $db = array(
	"QuickLinkHeading" => "HTMLText",
	"BlogHeading" => "HTMLText",
   );
   static $has_one = array(
   );
   function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->addFieldToTab('Root.Content.RightHandPanels', new HTMLEditorField('QuickLinkHeading','Events Heading Text'));
		$fields->addFieldToTab('Root.Content.RightHandPanels', new HTMLEditorField('BlogHeading','Blog Heading Text'));
		
		

	return $fields;
	}


}
class StandardPage_Controller extends Page_Controller {

	// blog posts
	function LatestNews($num=2) {
		$blog = DataObject::get_one("BlogHolder");
		return ($blog) ? DataObject::get("BlogEntry", "ParentID = $blog->ID", "Date DESC", "", $num) : false;
}

}
?>

Avatar
martimiz

Forum Moderator, 1391 Posts

16 August 2014 at 3:53am

Like below. As this is probably an older site (version 2.x) you can skip the 'private':

class StandardPage_Controller extends Page_Controller {

	static $allowed_actions = array(
		'LoyaltyForm'
 	);

	// blog posts
 	function LatestNews($num=2) { 
 	 	...

Avatar
Sly

Community Member, 4 Posts

19 August 2014 at 9:07am

Thank you so much martimiz!

That worked. The form now shows the success message when it is submitted. However the form does not get sent to the email.

I am not sure how I can find out which email address the LoyaltyForm is sent to, or how to fix the issue.

I appreciate you aren't familiar with this website, but do you know how I can see/change the email address the form is sent to. I'm not sure if it will be in the code or a setting in Silver Stripe Admin.

Avatar
kinglozzer

Community Member, 187 Posts

20 August 2014 at 3:36am

Hi Sly,

The code you pasted unfortunately doesn’t include the code used to generate & handle the form. I would guess that it’s most likely to be in the Page_Controller class (it’ll be in Page.php). If you can’t work it out yourself, paste the code for your Page_Controller here and someone should be able to help :)

Loz