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.

Customising the CMS /

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

FileField in Tab

Go to End

3 Posts   1602 Views


Community Member, 30 Posts

2 August 2011 at 6:30am


I'm creating new CMS compontent based on banner table. Baner has got image:

static $has_one = array(
'file' => 'File'

so I've created getCMSFields method:

public function getCMSFields() {

$fields = new FieldSet(
new TabSet("Root",
new Tab('Dane podstawowe',

new FileField( 'file', 'Baner', null, null, null, 'banery'),

and in BannerAdmin.php I've created edit form method

function getEditForm($id)

$actions = new FieldSet(
new FormAction('doUpdateBanner', 'Save')

$form = new Form($this, "EditForm", $fields, $actions);

return $form;

In cms form is created and has enctype multipart/form-data but when I submit firebug shows application/x-www-form-urlencoded; charset=utf-8 and $_FILES is empty. I don't know why enctype is changing.

In firebug I've spotted that submit input is outside <form> tags. But in everything is inside <form>… When I've moved (using firebug) sumit field inside <form> everything is ok. So it looks like submit is in wrong place. How can I fix it?


Administrator, 690 Posts

5 August 2011 at 10:06am

Hi Jarek,

Because the CMS is all Ajax based it doesn't handle file upload normally. You need to upload the file with an iframe. Fortunately there's a tool that does this for you. Use a FileIFrameField instead of a FileField and it should all be good.

If your file is going to be an image, you can use ImageField instead of FileIFrameField, which operates similarly but has thumbnails.



Community Member, 30 Posts

8 August 2011 at 10:51pm


where is code that submits form using ajax? It should be possible to set correct form enctype.

I've tried to use IFrameField but I'me getting "I can't handle sub-URLs of a xxx object" error