Witam,

Mam 2 formularze: CompanyForm i sfGuardUserForm. Company Form ma input do zapisywania zdjec. Odzielnie oba formularzedzialaja bezblednie. Problem w tym ze jak je polacze w jedem formularz, to dostaje ten blad: : Unknown record property / related component "Profil|company_logo" on "sfGuardUser"
Szukam juz caly dzien ale nie wiem jak to ugryzc.

Kod:

  1. class RegisterForm extends BasesfGuardUserForm
  2.  
  3. {
  4. public function configure()
  5. {
  6. $this->removeFields();
  7.  
  8. $this->widgetSchema['password'] = new sfWidgetFormInputPassword();
  9. $this->widgetSchema['password_confirmation'] = new sfWidgetFormInputPassword();
  10. $this->validatorSchema['username'] = new sfValidatorDoctrineUnique(array('model' => 'sfGuardUser', 'column' => 'username'));
  11.  
  12. $this->widgetSchema->setLabels(array(
  13. 'password' => '<span class="important">*</span>Hasło',
  14. 'password_confirmation' => '<span class="important">*</span>Potwierdź hasło',
  15. 'username' => '<span class="important">*</span>Nick',
  16. ));
  17.  
  18. $this->setValidators(array(
  19.  
  20. 'username' => new sfValidatorString(array('min_length' => 6, 'required' => true),
  21. array('required' => 'To pole jest wymagane',
  22. 'min_length' => 'Nick jest za krótki.
  23. Proszę podać minimalnie %min_length% znaków')),
  24.  
  25. 'password' => new sfValidatorString(array('min_length' => 6, 'required' => true),
  26. array('required' => 'To pole jest wymagane',
  27. 'min_length' => 'Hasło jest za krótkie.
  28. Proszę podać minimalnie %min_length% znaków')),
  29.  
  30. 'password_confirmation' => new sfValidatorString(array('min_length' => 6, 'required' => true),
  31. array('required' => 'To pole jest wymagane',
  32. 'min_length' => 'Potwierdzenie hasła jest za krótkie.
  33. Proszę podać minimalnie %min_length% znaków')),
  34. ));
  35.  
  36. $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_confirmation', array(),
  37. array('invalid' => 'Hasło i potwierdzenie hasła muszą być takie same')));
  38.  
  39. $companyForm = new CompanyForm($this->object->Company);
  40. //unset($companyForm['company_logo']);
  41. $this->embedMergeForm('Profil', $companyForm);
  42. }
  43.  
  44. protected function removeFields()
  45. {
  46. $this['is_active'],
  47. $this['is_super_admin'],
  48. $this['updated_at'],
  49. $this['groups_list'],
  50. $this['permissions_list'],
  51. $this['last_login'],
  52. $this['created_at'],
  53. $this['salt'],
  54. $this['algorithm']
  55. );
  56. }
  57.  
  58. }


  1. <?php
  2.  
  3. class CompanyForm extends BaseCompanyForm
  4. {
  5. public function configure()
  6. {
  7. $this->removeFields();
  8.  
  9. $this->widgetSchema['company_logo'] = new sfWidgetFormInputFileEditable(array(
  10. 'file_src' => '/'.basename(sfConfig::get('sf_upload_dir')).'/company/thumb/'.$this->getObject()->getCompanyLogo(),
  11. 'is_image' => true,
  12. 'delete_label' => 'usuń aktualne logo',
  13. 'edit_mode' => strlen($this->getObject()->getCompanyLogo()) > 0,
  14. 'template' => '<div>%file% %input%<br/>%delete% %delete_label%</div>'
  15. ));
  16.  
  17. $this->validatorSchema['company_logo'] = new sfValidatorFile(array(
  18. 'required' => false,
  19. 'mime_types' => 'web_images'
  20. ));
  21.  
  22. $this->widgetSchema->setLabels(array(
  23. 'first_name' => '<span class="important">*</span>Imię',
  24. 'last_name' => '<span class="important">*</span>Nazwisko',
  25. 'email' => '<span class="important">*</span>Adres e-mail',
  26. 'phone' => '<span class="important">*</span>Telefon',
  27.  
  28. 'company_name' => '<span class="important">*</span>Nazwa Firmy',
  29. 'company_nip' => '<span class="important">*</span>NIP',
  30. 'company_regon' => '<span class="important">*</span>Regon',
  31. 'company_address' => '<span class="important">*</span>Ulica',
  32. 'company_city' => '<span class="important">*</span>Miasto',
  33. 'company_postcode' => '<span class="important">*</span>Kod pocztowy',
  34. 'company_logo' => 'Logo firmy',
  35. ));
  36.  
  37. $this->validatorSchema['company_logo_delete'] = new sfValidatorPass();
  38.  
  39. $this->validatorSchema['company_name'] = new sfValidatorString(array('required' => true),
  40. array('required' => 'To pole jest wymagane'));
  41.  
  42. $this->validatorSchema['company_nip'] = new NipValidator(array('required' => true),
  43. array('required' => 'To pole jest wymagane',
  44. 'invalid' => 'NIP jest niepoprawny'));
  45.  
  46. $this->validatorSchema['company_regon'] = new RegonValidator(array('required' => true),
  47. array('required' => 'To pole jest wymagane',
  48. 'invalid' => 'Regon jest niepoprawny'));
  49.  
  50. $this->validatorSchema['company_address'] = new sfValidatorString(array('required' => true),
  51. array('required' => 'To pole jest wymagane'));
  52.  
  53. $this->validatorSchema['company_city'] = new sfValidatorString(array('required' => true),
  54. array('required' => 'To pole jest wymagane'));
  55.  
  56. $this->validatorSchema['company_postcode'] = new sfValidatorRegex(
  57. array('pattern' => '/^[0-9]{2}-?[0-9]{3}$/', 'required' => true),
  58. array('invalid'=>'Nieprawidłowy kod pocztowy.',
  59. 'required' => 'To pole jest wymagane'));
  60.  
  61. $this->validatorSchema['first_name'] = new sfValidatorString(array('required' => true),
  62. array('required' => 'To pole jest wymagane'));
  63.  
  64. $this->validatorSchema['last_name'] = new sfValidatorString(array('required' => true),
  65. array('required' => 'To pole jest wymagane'));
  66.  
  67. $this->validatorSchema['phone'] = new sfValidatorString(array('required' => true),
  68. array('required' => 'To pole jest wymagane'));
  69.  
  70. $this->validatorSchema['email'] = new sfValidatorEmail(array('required' => true),
  71. array('invalid' => 'Adres e-mail jest niepoprawny',
  72. 'required' => 'To pole jest wymagane'));
  73. }
  74.  
  75. protected function removeFields()
  76. {
  77. unset($this['user_id'],
  78. $this['slug'],
  79. $this['id'],
  80. $this['is_activated']);
  81. }
  82.  
  83. public function updateObject()
  84. {
  85. $image = $this->getValue('company_logo');
  86. $filename = $this->object->getCompanyLogo();
  87.  
  88. $file = sfConfig::get('sf_web_dir').'/uploads/company/'.$filename;
  89. $thumb = sfConfig::get('sf_web_dir').'/uploads/company/thumb/'.$filename;
  90.  
  91. if ($image)
  92. {
  93. // remove old image
  94. if (file_exists($file))
  95. {
  96. @unlink($file);
  97. }
  98.  
  99. if (file_exists($thumb))
  100. {
  101. @unlink($thumb);
  102. }
  103. }
  104.  
  105. // update the product
  106. parent::updateObject();
  107.  
  108. if ($image)
  109. {
  110. // save new image
  111. $filename = sha1($image->getOriginalName()).$image->getExtension($image->getOriginalExtension());
  112. $image->save(sfConfig::get('sf_web_dir').'/uploads/company/'.$filename);
  113.  
  114. $thumbnail = new sfThumbnail(300, 300);
  115. $thumbnail->loadFile(sfConfig::get('sf_web_dir').'/uploads/company/'.$filename);
  116. $thumbnail->save(sfConfig::get('sf_web_dir').'/uploads/company/'.$filename);
  117.  
  118. $thumbnail = new sfThumbnail(150, 150);
  119. $thumbnail->loadFile(sfConfig::get('sf_web_dir').'/uploads/company/'.$filename);
  120. $thumbnail->save(sfConfig::get('sf_web_dir').'/uploads/company/thumb/'.$filename);
  121. }
  122.  
  123. if ( $this->getValue('company_logo_delete') )
  124. {
  125. @unlink($file);
  126. @unlink($thumb);
  127. }
  128.  
  129. $this->object->setCompanyLogo($filename);
  130. }
  131.  
  132. }



  1. <form action="<?php echo url_for('@register_confirm') ?>" method="POST">
  2.  
  3. <?php echo $form['_csrf_token']; ?>
  4. <?php echo $form->renderGlobalErrors() ?>
  5.  
  6. <table class='form_table'>
  7. <tr><td colspan="2"><h2>Dane osobowe</h2></td></tr>
  8. <?php echo $form['Profil|first_name']->renderRow(array('class' => 'input')) ?>
  9. <?php echo $form['Profil|last_name']->renderRow(array('class' => 'input')) ?>
  10. <?php echo $form['Profil|email']->renderRow(array('class' => 'input')) ?>
  11. <?php echo $form['Profil|phone']->renderRow(array('class' => 'input_short')) ?>
  12. <tr><td colspan="2"><h2>Dane firmy</h2></td></tr>
  13. <?php echo $form['Profil|company_name']->renderRow(array('class' => 'input')) ?>
  14. <?php echo $form['Profil|company_nip']->renderRow(array('class' => 'input')) ?>
  15. <?php echo $form['Profil|company_regon']->renderRow(array('class' => 'input')) ?>
  16. <?php echo $form['Profil|company_address']->renderRow(array('class' => 'input')) ?>
  17. <?php echo $form['Profil|company_city']->renderRow(array('class' => 'input')) ?>
  18. <?php echo $form['Profil|company_postcode']->renderRow(array('class' => 'input_short')) ?>
  19. <tr><td colspan="2"><h2>Logo firmy</h2></td></tr>
  20. <?php echo $form['Profil|company_logo']->renderRow(array('class' => 'input')) ?>
  21. <tr><td colspan="2"><h2>Logowanie</h2></td></tr>
  22. <?php echo $form['username']->renderRow(array('class' => 'input_short')) ?>
  23. <?php echo $form['password']->renderRow(array('class' => 'input_short')) ?>
  24. <?php echo $form['password_confirmation']->renderRow(array('class' => 'input_short')) ?>
  25. <tr><td width="25%">&nbsp;</td><td>&nbsp;</td></tr>
  26. <tr>
  27. <td colspan="2" align="center">
  28. <input type="submit" value="Rejestruj" />
  29. </td>
  30. </tr>
  31. </table>
  32.  
  33. </form>