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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Front End DataObjectManager - Page Not Found


Go to End


834 Views

Avatar
CHD

Community Member, 219 Posts

4 March 2012 at 11:07am

can anybody help with this?

I've go a front end dataobjectmanager (or complextable - either is fine) and it lists my dataobjects fine, but when i click them or try to add a new one it just ends with "page not found"

here's my code:

<?php
class Rates extends DataObject {
	public static $db = array(
		  
		"PricePerNight" => "Currency",
		"dateStart" => "Date",
		"dateEnd" => "Date"
	);

	public static $has_one = array(
		"Apartment" => "Apartment"
	);
	
	public static $has_many = array(
	);
	

	
	public function getCMSFields_forPopup() {
		return new FieldSet(
			new TextField('PricePerNight'),
			new DatePickerField ('dateStart','Date of arrival'),
			new DatePickerField ('dateEnd','Date of departure')
		);
	}

}


*********************************************

	function RatesForm(){
	$Apartment = $this->getApartment();	
	$Manager = new ComplexTableField(
		$this,
		'Rates',
		'Rates',
		array('dateStart' => 'dateStart'),
		'getCMSFields_forPopup',
		'ApartmentID = ' . $Apartment->ID
		);
	$Manager->setParentClass('Rates');
	$Manager->setPermissions(array("show","edit", "add"));
	
	$fields = new FieldSet(
   new HiddenField('ID', ''),
   $Manager
);

	
	return new Form($this, 'RatesForm', $fields, new FieldSet());
} 

I'm guessing the issue is because i'm generating the form on an external page type to where the "Rates" are initially managed. so is it to do with the controllers?
I think the problem may lie here:

$Manager = new ComplexTableField(
$this,

Does the $this need to be something else?

I have the following relationships.
"Apartments" are dataobjects - they $has_many "Rates"
"Rates" are dataobjects - they $has_one "Apartment"

And im tryng to have a form that loads on my front end "edit" page with a URL like this: mysite.com/account/your-listings/rates/apartment-name

It all shows up fine in the front end, and ONLY the rates that apply to that Apartment appear, it's just I cant click/edit/delete them.

thanks in advance for your help!