This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

thiago9438
thiago9438

Hi, i need to add some fields like: "Button text" for the System\Models\File:

alt text

Can someone help me? Thanks!

Scott
Scott

This has been discussed a few times before, you can extend the File model the same as you would any other model. To my knowledge though, you can't extend the form (or at least you can't do it the way you would normally extend forms). The file details modal is just a partial, not a form which can be extended. Hopefully this will be made a bit more flexible in the future.

Last updated

Mohsin
Mohsin

I came looking for this as well. I think it would be nice to have an additional ‘model’ attribute to explicitly specify an additional model from which form fields can be added to this partial.

sercanvirlan
sercanvirlan

it will be awesome i think

Mohsin
Mohsin

Not just that... It would also be nice if there was some mechanism to specify any custom behaviour on file upload. For example, for one of my projects I added this code to modules/backend/formwidgets/FileUpload.php

$file->title = preg_replace('/\.?' . $uploadedFile->getClientOriginalExtension() . '$/', '', $uploadedFile->getClientOriginalName());

This basically fills the title field automatically with the file name minus the extension. It was a requirement for the project since the photos were taken by several people and I had told them specifically how to name the image files before submitting it to me for uploading.

When I updated OctoberCMS via the backend system update, this code got re-written and I had to edit the file again to add it. It's not a good solution since it will go away each time I update. There should be a better mechanism to do this.

Last updated

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.