2011-07-08 4 views
0

私はsymfony 1.4.11を使用しています。私はフロントエンドとバックエンドのフォームを持っています。symfonyバックエンドフォーム

フロントエンド:

<?php 

{ 
    public function configure() 
    { 

    $user = sfContext::getInstance()->getUser()->getGuardUser()->getProfile(); 

    $this->removeFields(); 


$this->widgField(); 
     $this->widgetSchema->setLabels(array(
    'time_id' => 'Duration *', 

    )); 
    } 

protected function removeFields() 
    { 
unset(

     $this['created_at'], 
     $this['updated_at'], 
     $this['is_closed'], 
     $this['invoice_url'], 
     $this['is_cancel'] 
    ); 
    } 

    protected function widgField() 
    { 
$this->widgetSchema['user_id'] = new sfWidgetFormInputHidden(); 
    } 


    protected function doUpdateObject($values) 
    { 
    parent::doUpdateObject($values); 
    $this->getObject()->setUserId(sfContext::getInstance()->getUser()->getGuardUser()->getId()); 
    } 
} 

とバックエンドは:

<?php 
class BackendPaymentForm extends PaymentForm 
{ 
    public function configure() 
    { 
    parent::configure(); 


    } 

    protected function removeFields() 
    { 
    unset(
    $this['updated_at'], 
    $this['created_at'], 
    $this['user_id'], 
    $this['time_id'], 
    $this['invoice_url'], 
    $this['is_cancel'] 

    ); 
    } 
    protected function widgField() 
    { 

    } 

} 

?> 

問題がある、私はフロントエンドuser_idの設定doUpdateObject、中にバックエンドに持っている私は、その管理者は一つのパラメータを設定することができます必要がありますそれはすべてokですが、それはadmin_idにuser_idを変更します...ありがとう!

+0

:私はそれを修正、私はわずか8時間後に答えを投稿:( – denys281

答えて

0

更新、私はそれが良い方法ですしていないが、それは仕事です:)

class BackendPaymentForm extends PaymentForm 
{ 
    public function configure() 
    { 
    parent::configure(); 


    } 

    protected function removeFields() 
    { 
    unset(
    $this['updated_at'], 
    $this['created_at'], 
    $this['time_id'], 
    $this['invoice_url'], 
    $this['is_cancel'] 

    ); 
    } 
    protected function widgField() 
    { 
$this->widgetSchema['user_id'] = new sfWidgetFormInputHidden(); 
    } 


protected function doUpdateObject($values) 
    { 
    parent::doUpdateObject($values); 
    $this->getObject()->setUserId($values['user_id']); 
    } 
}