Hi,
if i configure a form embedding a i18n form the system try to insert the
value from the i18n form before inserting the other values.
The submition fails because doctrine complains that it hasn't an fk id.
If I comment out the validation form method($this->addValidators()),
everything works fine... why?
1. <?php
2.
3. /**
4. * Album form.
5. *
6. * @package form
7. * @subpackage Album
8. * @version SVN: $Id: sfDoctrineFormTemplate.php 6174 2007-11-27
06:22:40Z fabien $
9. */
10. class BackendAlbumForm extends BaseAlbumForm
11. {
12.
13. public function __construct(sfDoctrineRecord $object = null,
$options = array <http://www.php.net/array>(), $CSRFSecret = null)
14. {
15. $options['culture'] = sfContext::getInstance()->getUser()->
getCulture();
16.
17. parent::__construct($object, $options, $CSRFSecret);
18. }
19.
20.
21. public function configure()
22. {
23. $this->removeFields();
24. $this->embedI18n(array <http://www.php.net/array>('en', 'it'));
25.
26. $this->addWidgets();
27. $this->addValidators();
28. $this->addDefaults();
29.
30.
31.
32. }
33.
34. private function addWidgets()
35. {
36.
37. $this->widgetSchema['table_id'] = new sfWidgetFormInputHidden();
38. $this->widgetSchema['label_id'] = new sfWidgetFormInputHidden();
39. //image file
40.
41. $this->widgetSchema['cover_image'] = newsfWidgetFormInputFileEditable
(
42.
array<http://www.php.net/array>
('file_src' => '/uploads/albums/'.$this->getObject()->getCoverImage(),
43. 'is_image' =>
true,
44. 'with_delete' =>
false,
45. 'template'
=> '<div>%file%<br
/>%input%<br />%delete% %delete_label%</div>',)
46. );
47. $this->widgetSchema['artists_list'] =
newsfWidgetFormDoctrineChoiceMany
(array <http://www.php.net/array>('model' => 'Artist', 'table_method' =>
'getArtistsLabel'));
48. }
49.
50. private function addValidators()
51. {
52. $this->validatorSchema['table_id'] = newsfValidatorDoctrineChoice
(array <http://www.php.net/array>('model' => 'TableName',
53.
'column' => 'id',
54.
'required' => true));
55.
56.
57. //FIXME check if it's a lable type user
58. $this->validatorSchema['label_id'] = newsfValidatorDoctrineChoice
(array <http://www.php.net/array>('model' => 'sfGuardUser',
59.
'column' => 'id',
60.
'required' => true));
61.
62.
63.
64. $this->validatorSchema['cover_image'] = new sfValidatorPass();
65.
66. $this->validatorSchema['artists_list'] =
newsfValidatorDoctrineChoiceMany
(array <http://www.php.net/array>('required' => true, 'model' =>
'sfGuardUser', 'query' => ArtistTable::getArtistsLabelQuery()));
67. }
68.
69. private function addDefaults()
70. {
71. $this->setDefaults(array <http://www.php.net/array>('table_id' =>
'1', 'label_id' => '1'));
72. }
73.
74. protected function processUploadedFile($field, $filename = null,
$values = null)
75. {
76.
77.
78. [...] omitted
79.
80. }
81.
82. private function removeFields()
83. {
84. unset <http://www.php.net/unset>( $this['created_at'], $this[
'updated_at'], $this['songs_list']);
85. }
86.
87. public function getCurrentCulture()
88. {
89. return isset <http://www.php.net/isset>($this->options['culture']
) ? $this->options['culture'] : 'it';
90. }
91.
92. }
thanks
cirpo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---