I have a model Poster and the server stores images. So the model has a filename field. I have a form class MakenewForm.php and I need to override its doSave() so as to achieve a save for a Poster object. the MakenewForm has a text field which is written over a preset image using imagettftext. so for saving, I need to
1. save the modified image data onto a file in the filesystem.
2. save an object of Poster class with filename field set to the newly saved file
For step 1, I want to get a random name for the new file. I know that symfony uses random file naming for uploaded files(file input widget and file validator), I would like to use the same function but I can’t find out which it is.
For step 2, I’m a bit confused due to this $con variable. What is its use? and How do I use it to meet my needs? Well, I can always achieve saving by making an object of PosterForm and setting appropriate fields and calling doSave for it. But I’d like to override the default doSave() function of the form. My MakenewForm extends PosterForm 😛
Step 1: the function is
generateFilenameand it is insfValidatedFile.class.phpfile (source file, also look at this forum post)Step 2: look at the form documentation, on file upload section, specially listing 2-20, where is show how to save a file from a form with a file name of choice