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.

Form Questions /

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

Noob Form question


Go to End


3 Posts   1209 Views

Avatar
YourMan

Community Member, 5 Posts

5 March 2011 at 6:36am

Hi,

I'm pretty sure this is very simple and I'm doing this horriblely wrong or something.

What I'm try to do , Is that i have a form that submits an image.
it then crops bits of the image into new images , i want to display these as the return of the submission of the form.

what I'm not sure of how do do is to pass the paths to the images i have created to the template.
Any help would be cool

Avatar
swaiba

Forum Moderator, 1899 Posts

6 March 2011 at 11:20pm

Edited: 06/03/2011 11:20pm

What I'm try to do , Is that i have a form that submits an image.
it then crops bits of the image into new images , i want to display these as the return of the submission of the form.

first part is with SimpleImageField or Uploadify, no idea about splitting the image up...

what I'm not sure of how do do is to pass the paths to the images i have created to the template.
You can pass data into a template in many ways, is this data written to the database? If so place...

function CroppedImages() {
	return DataObject::get('MyCroppedImages');
}

if it isn't then simply place your data into the same structure manually...

function CroppedImages() {
	$arr = array('data1','data2');
	$dos= new DataObjectSet();
	foreach ($arr as $str) {
		$do= new DataObject();
		$do->ImageName = $str;
		$dos->push($do);
	}
	return $dos;
}

Avatar
YourMan

Community Member, 5 Posts

9 March 2011 at 8:24am

Thanks swaiba for your reply.

The area I'm really having problems with is the flow of returning a page after a form has been submitted.
I'm not using a database , so the DataObjectSet is what i want alright thanks.

The code I have so far returns a blank page:
http://www.sspaste.com/paste/show/4d7674ab061a7

myTemplate is just : <h1>hello</h1>

after that, My problem now is accessing the DataObjectSet from the template, maybe a control loop , but not sure how to access arrays in the template language.