Search code examples
phpsymfony1symfony-1.4symfony-forms

Symfony Set value of a form field in doSave


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.


Solution

  • 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);