【发布时间】:2012-06-13 22:20:41
【问题描述】:
我正在尝试在 sfGuard 插件的用户表单中添加自定义字段。
我已经在数据库中创建了列,并为该字段添加了 widgetschema。它在表单中正确显示,当添加和提交文本时,它显示更新成功。但是,插入该字段的数据并未填充到数据库中。
我想我必须更新 sfGuard 的模型,因为它不知道新字段。我试过$ ./symfony doctrine:build-model,但这似乎并没有更新 sfGuard 插件中的类。
我已将此添加到 sfGuardUserAdminClass :
$this->widgetSchema['department_title'] = new sfWidgetFormInputText();
$this->validatorSchema['department_title'] = new sfValidatorString(array());
我可以看到表单字段并提交,它只是没有捕获数据并将数据插入到数据库中。
更新
我已经使用 MyUser 对象更新了我的架构,迁移了差异并构建了模型。我在 sfGuardUserAdminForm.class 中添加了$this->embedRelation('Profile');。我收到此错误
"Catchable fatal error: Argument 1 passed to sfUser::__construct() must be an instance of sfEventDispatcher, instance of MyUserTable given, called in /Users/careyestes/Sites/sva/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Table.php on line 301 and defined in /Users/careyestes/Sites/sva/lib/vendor/symfony/lib/user/sfUser.class.php on line 46 Fatal error: Call to a member function evictAll() on a non-object in /Users/careyestes/Sites/sva/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php on line 1239"
【问题讨论】:
-
对不起,MyUser 的名称可能是错误的,因为它也是 sfUser 的默认类的名称。尝试在架构中将名称从 MyUser 更改为 MyUserProfile。我更新了我的答案。
标签: symfony1 symfony-1.4 symfony-forms sfguard