【发布时间】:2011-12-11 18:07:06
【问题描述】:
我有一个模型Poster,服务器存储图像。所以模型有一个filename 字段。我有一个表单类MakenewForm.php,我需要覆盖它的doSave(),以便保存Poster 对象。 MakenewForm 有一个文本字段,它使用imagettftext 覆盖在预设图像上。所以为了节省,我需要
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
对于第 1 步,我想为新文件获取一个随机名称。我知道 symfony 对上传的文件使用随机文件命名(file input widget and file validator),我想使用相同的功能,但我不知道它是什么。
对于第 2 步,由于这个 $con 变量,我有点困惑。它的用途是什么?以及如何使用它来满足我的需求?好吧,我总是可以通过创建PosterForm 的对象并设置适当的字段并为此调用doSave 来实现保存。但我想覆盖表单的默认 doSave() 函数。我的MakenewFormextendsPosterForm:P
【问题讨论】:
标签: php symfony1 doctrine symfony-1.4 symfony-forms