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:
class RegisterForm extends BasesfGuardUserForm { public function configure() { $this->removeFields(); $this->widgetSchema['password'] = new sfWidgetFormInputPassword(); $this->widgetSchema['password_confirmation'] = new sfWidgetFormInputPassword(); $this->validatorSchema['username'] = new sfValidatorDoctrineUnique(array('model' => 'sfGuardUser', 'column' => 'username')); 'password' => '<span class="important">*</span>Hasło', 'password_confirmation' => '<span class="important">*</span>Potwierdź hasło', 'username' => '<span class="important">*</span>Nick', )); 'min_length' => 'Nick jest za krótki. Proszę podać minimalnie %min_length% znaków')), 'min_length' => 'Hasło jest za krótkie. Proszę podać minimalnie %min_length% znaków')), 'min_length' => 'Potwierdzenie hasła jest za krótkie. Proszę podać minimalnie %min_length% znaków')), )); $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_confirmation', array(), $companyForm = new CompanyForm($this->object->Company); //unset($companyForm['company_logo']); $this->embedMergeForm('Profil', $companyForm); } protected function removeFields() { $this['is_active'], $this['is_super_admin'], $this['updated_at'], $this['groups_list'], $this['permissions_list'], $this['last_login'], $this['created_at'], $this['salt'], $this['algorithm'] ); } }
<?php class CompanyForm extends BaseCompanyForm { public function configure() { $this->removeFields(); 'file_src' => '/'.basename(sfConfig::get('sf_upload_dir')).'/company/thumb/'.$this->getObject()->getCompanyLogo(), 'is_image' => true, 'delete_label' => 'usuń aktualne logo', 'template' => '<div>%file% %input%<br/>%delete% %delete_label%</div>' )); 'required' => false, 'mime_types' => 'web_images' )); 'first_name' => '<span class="important">*</span>Imię', 'last_name' => '<span class="important">*</span>Nazwisko', 'email' => '<span class="important">*</span>Adres e-mail', 'phone' => '<span class="important">*</span>Telefon', 'company_name' => '<span class="important">*</span>Nazwa Firmy', 'company_nip' => '<span class="important">*</span>NIP', 'company_regon' => '<span class="important">*</span>Regon', 'company_address' => '<span class="important">*</span>Ulica', 'company_city' => '<span class="important">*</span>Miasto', 'company_postcode' => '<span class="important">*</span>Kod pocztowy', 'company_logo' => 'Logo firmy', )); $this->validatorSchema['company_logo_delete'] = new sfValidatorPass(); 'invalid' => 'NIP jest niepoprawny')); 'invalid' => 'Regon jest niepoprawny')); $this->validatorSchema['company_postcode'] = new sfValidatorRegex( 'required' => 'To pole jest wymagane')); 'required' => 'To pole jest wymagane')); } protected function removeFields() { $this['slug'], $this['id'], $this['is_activated']); } public function updateObject() { $image = $this->getValue('company_logo'); $filename = $this->object->getCompanyLogo(); $file = sfConfig::get('sf_web_dir').'/uploads/company/'.$filename; $thumb = sfConfig::get('sf_web_dir').'/uploads/company/thumb/'.$filename; if ($image) { // remove old image { } { } } // update the product parent::updateObject(); if ($image) { // save new image $filename = sha1($image->getOriginalName()).$image->getExtension($image->getOriginalExtension()); $image->save(sfConfig::get('sf_web_dir').'/uploads/company/'.$filename); $thumbnail = new sfThumbnail(300, 300); $thumbnail->loadFile(sfConfig::get('sf_web_dir').'/uploads/company/'.$filename); $thumbnail->save(sfConfig::get('sf_web_dir').'/uploads/company/'.$filename); $thumbnail = new sfThumbnail(150, 150); $thumbnail->loadFile(sfConfig::get('sf_web_dir').'/uploads/company/'.$filename); $thumbnail->save(sfConfig::get('sf_web_dir').'/uploads/company/thumb/'.$filename); } if ( $this->getValue('company_logo_delete') ) { } $this->object->setCompanyLogo($filename); } }
<table class='form_table'> <tr><td colspan="2"><h2>Dane osobowe</h2></td></tr> <tr><td colspan="2"><h2>Dane firmy</h2></td></tr> <tr><td colspan="2"><h2>Logo firmy</h2></td></tr> <tr><td colspan="2"><h2>Logowanie</h2></td></tr> <tr><td width="25%"> </td><td> </td></tr> <tr> <td colspan="2" align="center"> <input type="submit" value="Rejestruj" /> </td> </tr> </table> </form>