Jump to:

23576 Posts in 19403 Topics by 2893 members

General Questions

SilverStripe Forums » General Questions » Resizing an image within a form

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 666 Views
  • joelg
    Avatar
    Community Member
    129 Posts

    Resizing an image within a form Link to this post

    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

    666 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.