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:

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

Resizing an image within a form


Go to End


847 Views

Avatar
joelg

Community Member, 134 Posts

1 July 2010 at 9:20pm

Hi there

How can I resize an image inside a form?

Suppose I would like to do something like this:

function ImageForm()
{
	$Employee = Employee::currentUser();
	$Image = $Employee->Picture();
		
	$form = new Form($this, "Form", 
                      new FieldSet(
		            new LiteralField(''myLiteralField", $Image->paddedResize(200,200)
                      ), 
		      new FieldSet(
		            new FormAction ($action = "myAction", $title = "Save")
                      ), 
                      new RequiredFields());
	
        //I know there is actually no formfields in this form, this is just an example...
		
	return $form;
}

Thanks, Joel