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

AddFrom not getting data / not creating the page


Go to End


3 Posts   483 Views

Avatar
lozhowlett

Community Member, 151 Posts

23 January 2014 at 4:16am

I am having a bad day with silverstripe today. I have just downloaded a whole new version of silevrstripe, gridfieldbulkingeditingtools, sortablegridfield, widgets.

I have created my page type...

<?php
class Page extends SiteTree {

	private static $db = array(
	);

	private static $has_one = array(
		"TopImage" => "Image"
	);

	private static $has_many = array(
		'ContentBlockVerticals' => 'ContentBlockVertical',
		'ContentBlockHorzs' => 'ContentBlockHorz',
		'Faqs' => 'Faq',
		'LowerCallToActions' => 'LowerCallToAction'
	);

	function getCMSFields() {
		$fields = parent::getCMSFields();

        $gridFieldConfig  = GridFieldConfig_RecordEditor::create();
        $ContentBlockVerticals = new GridField("ContentBlockVerticals", "Content Block Vertical", $this->ContentBlockVerticals(), $gridFieldConfig);	
        
        $gridFieldConfig  = GridFieldConfig_RecordEditor::create();
        $ContentBlockHorzs = new GridField("ContentBlockHorzs", "Contact Block Horz", $this->ContentBlockHorzs(), $gridFieldConfig);	
        
        $gridFieldConfig  = GridFieldConfig_RecordEditor::create();
        $Faqs = new GridField("Faqs", "Faqs", $this->Faqs(), $gridFieldConfig);	
        
        $gridFieldConfig  = GridFieldConfig_RecordEditor::create();
        $LowerCallToAction = new GridField("LowerCallToActions", "LowerCallToAction", $this->LowerCallToActions(), $gridFieldConfig);	


		$contentblocks = new TabSet(
                $name = "ContentBlockTabs",
                
                new Tab(
                        $title='Vertical Blocks',
                        new HeaderField("Content Block Vertical"),
                        $ContentBlockVerticals
                ),
                new Tab(
                        $title='Horizontal Blocks',
                        new HeaderField("Contact Block Horz"),
                        $ContentBlockHorzs
                ),
                new Tab(
                        $title='Faqs',
                        new HeaderField("Faqs"),
                        $Faqs
                ),
                new Tab(
                        $title='Lower CTAs',
                        new HeaderField("Lower CTAs"),
                        $LowerCallToAction
                )
        );

		$fields->addFieldToTab('Root.ContentBlocks', $contentblocks );

		return $fields;
	}

}
class Page_Controller extends ContentController implements PermissionProvider {

	/**
	 * An array of actions that can be accessed via a request. Each array element should be an action name, and the
	 * permissions or conditions required to allow the user to access it.
	 *
	 * <code>
	 * array (
	 *     'action', // anyone can access this action
	 *     'action' => true, // same as above
	 *     'action' => 'ADMIN', // you must have ADMIN permissions to access this action
	 *     'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
	 * );
	 * </code>
	 *
	 * @var array
	 */
	private static $allowed_actions = array (
		"logout"
	);

	public function init() {
		parent::init();
	}

	function providePermissions(){
        return array('REGISTERED_USER' => 'Registered user of expense system');
    }

    function logout() { 
	   Security::logout(false); 
	   Controller::redirect("members/"); 
	}


}

and for some reason when I add any page type, or dataobject it just "hangs", but does actually add it. It seems AddForm is getting no data when putting break points in the ajax function...

var newContentEls = self.handleAjaxResponse(data, status, xhr);

data = null

I really dont understand why its doing this at all - lost 4 hours to it so far!!

Thanks

Avatar
lozhowlett

Community Member, 151 Posts

23 January 2014 at 5:14am

Its something to do with these two pages, as when I delete them it all starts working again.

 <?php
class LogInPage extends Page {

	private static $db = array(
	);

	private static $has_one = array(
	);

	private static $has_many = array(
	);

	public function getCMSFields() {
   		$fields = parent::getCMSFields();
		return $fields;
  }



}
class LogInPage_Controller extends Page_Controller {


	// private static $allowed_actions = array (
	// 	"LoginForm"
	// );

	// function LoginForm() {
 //        $form = new CustomLogin($this,"LoginForm");
 //        // print_r($_REQUEST);
 //        return $form;
 //    }



}

 <?php
class LoggedInPage extends Page {

	private static $db = array(
	);

	private static $has_one = array(
	);

	private static $has_many = array(

	);

	public function getCMSFields() {
   		$fields = parent::getCMSFields();
		return $fields;
  	}

  

}
class LoggedInPage_Controller extends Page_Controller {

	// function ExpenseClaims(){

	// 	//Get PersonID from current Member
	// 	$persons = Person::get()->filter(array("MemberID"=>Member::currentUserID())); 
	// 	if(!$persons){
	// 		return Controller::redirect("/");	
	// 	}
	// 	//stupid SS needs this to actually get the record!!
	// 	foreach($persons as $Person) {
	// 		return ExpenseClaim::get()->where("PersonID=".$Person->ID);
	// 	}

	// }

}

Any ideas?

Avatar
lozhowlett

Community Member, 151 Posts

23 January 2014 at 5:19am

Fixed!! It was a space at the start of a file! Jesus, 5 hours wasted!