Reputation: 9606
I need to override my form like this:
protected function doSave($con = null)
{
$filename= Helper::generateFilename($this->getValue('name')).'jpg';
imagejpeg(Helper::createImage($this->getValues()), sfConfig::get('sf_upload_dir').'/poster/'.$filename );
/* Here I need to set value of *fielname* field of the form equal to
$filename */
parent::doSave($con);
}
Helper.class.php
is located in /lib/
so it acts like a helper class.
generateFilename
actually gives a randomized string. since there is no function like setValue
in a form, I'm stuck.
Upvotes: 0
Views: 2778
Reputation: 39
I tried macgyver's approach but didn't work for me. Not sure if I did anything wrong. Syfmony version is 1.4 with Doctrine.
I had to override the updateObject() function inside the form class. In my case its inside TimesheetForm.class.php. I had to change the status of the timesheet based on user action.
Following is the piece of code that that I tried. It did update the object before saving. Which was seen effected in the db.
public function updateObject($values = null)
{
$object = parent::updateObject($values);
$object->setStatus("Submitted");
return $object;
}
I didn't impelement/override the doSave() function. I'm using symfony 1.4. Hope the above helps.
Upvotes: 1
Reputation: 1279
You have to use, say you have used filename
as field in your schema to store the image filename, $this->object->setFilename($filename);
before parent::doSave($con);
Upvotes: 0