If you have unique = true and notnull = true then you have to assign a unique filename before you save the object, or you would have an exception. The better way would be to just assign a random name, as Georg says. If you really need the ID on the name, then first assign a random name and, after the parent::doSave( $con ) assign the ID again to the filename.
On Thu, Aug 19, 2010 at 6:17 PM, Georg <geor...@have2.com> wrote: > Why don't you give it just a random name? > > Am 19.08.2010 21:55, schrieb Alexis Sanchez: > > Hi! > > > > I have a doctrine model like this: > > > > Asset: > > columns: > > filename: { type: string(255), notnull: false, unique: true } > > filesize: { type: integer, notnull: true } > > > > In the saving process I want to check if the user has left the > > filename empty. In that case i want to set the filename with the id of > > the object. > > > > The problem is that I don't know where the Id of the object is aviable > > in the saving process. żhave I to do it in the doSave method? żafter o > > before calling the parent::doSave???? > > > > I want to do something like this: > > > > public function doSave($con = null) > > { > > > > if(null === $this->getObject()->getFilename()){ > > $this->getObject()->setFilename($this->getObject()- > >> getId()); > > } > > > > parent::doSave($con); > > } > > > > -- > If you want to report a vulnerability issue on symfony, please send it to > security at symfony-project.com > > You received this message because you are subscribed to the Google > Groups "symfony users" group. > To post to this group, send email to symfony-users@googlegroups.com > To unsubscribe from this group, send email to > symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/symfony-users?hl=en > -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en