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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

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

Forms on dataobjects

Go to End



Community Member, 201 Posts

3 March 2013 at 10:38am

Edited: 03/03/2013 11:33am

Hi guys,

Ok i need a bit of help.

I have a data object called SEARCH this lists info about a search (supprise supprise) each SEARCH can have many MISPERS. I have a SEARCHPAGE that lists all the current searches when i select a link it takes me to the rendered page for showing me the SEARCH and the MISPER details. what i would like to do is add a link in the page that allows me to edit the MISPER detail i am looking at.This is where i seem to have confused myself and now cannot see the wood from the trees.
I don't have a huge amount of knowledge on the whole MVC type approach but what i would like to happen is that the dataobject MISPER has a form on it that i can call in the rendered searchpage so far i've got that working but when i try to save said form it doesn't work it doesn't seem to know where to send/process the data. I'm sure this is due to a lack of controller and i'm used to using forms on an actual defined Pages. So i need to work out how to process a form that is on a dataobject.
If i try and process the form on the rendered search page i'm not sure how to pass the correct ID for the MISPER bearing in mind there could be multiple MISPERS per search on that page.

Any help or pointers appreciated.



class Search extends DataObject implements PermissionProvider  {
   	static $db = array(
   		'Name' => 'Varchar(50)',
		'IncidentNum' => 'int',
   		'CalloutDate' => 'SS_Datetime',
		'Area' => 'Varchar(250)',
		'Notes' => 'Text',
		'RVGridref' => 'Varchar(20)',
		'CurrentSearch' => 'Boolean',
	static $has_many = array (
		'AuditTrails' => 'AuditTrail',
		'Locations' => 'Location',
		'Contacts' => 'Contact',
		'Mispers' => 'Misper'

class Misper extends DataObject  {
   static $db = array(
   	'Name' => 'Varchar(50)',
	'Nickname' => 'Varchar(50)',
	'MispNum' => 'Varchar(5)',	
	'Age' => 'Varchar(20)',
	'Race' => 'Varchar(50)',
	'Gender' =>  "Enum( array('Male','Female'),'Male')",
	'Height' => 'Varchar(10)',
	'Weight' => 'Varchar(50)',
	'Hair' => 'Varchar(75)',
	'FacialHair' => 'Varchar(50)',
	'DOB' =>  'Date',
	'Notes' => 'Text',
	'SearchedBefore' => 'Boolean',
	'Shirt' => 'Varchar(50)',
	'Jumper' => 'Varchar(50)',
	'Jacket' => 'Varchar(50)',
	'Headwear' => 'Varchar(50)',
	'Trousers' => 'Varchar(50)',
	'Footwear' => 'Varchar(50)',
	'Gloves' => 'Varchar(50)',
	'Glasses' => 'Varchar(50)',
	'Description' => 'Text',
   static $has_one = array (
		'Photo' => 'Image',
		'Search' => 'Search'

function MisperClothing() {
	$fields = new FieldList(
	HiddenField::create('ID', 'aID', $this->ID),
	//HiddenField::create('MemberID', 'aID', $member),
	HeaderField::create('LocationHeader' ,  'Misper Clothing' , 3),
	TextField::create("Jumper", "Jumper"),
	$actions = FieldList::create(
            FormAction::create("doMisperClothing","Update Mipser")
	$form = Form::create($this, 'MisperClothing', $fields,  $actions);
	$editmis = Misper::get()->filter('ID', $this->ID)->First();
	return $form;
function doMisperClothing($data, $form){

	$theID = $_POST["ID"];
	$mis = Misper::get()->byID($theID);

	<% with getSearch %>
		<% loop Mispers %>
		<% end_loop %>
	<% end_with %>