public function configure()
 {
     parent::configure();
     $this->widgetSchema['created_at'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['updated_at'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['user_id'] = new sfWidgetFormInputHidden();
     if ($this->getObject()->user_id != null) {
         unset($this['author_email'], $this['author_website'], $this['author_name']);
         $this->widgetSchema['user_name'] = new sfWidgetFormInput(array(), array('readonly' => 'true'));
         $this->widgetSchema['user_name']->setLabel(__('Name', array(), 'vjComment'))->setDefault($this->getObject()->getUser()->getUsername());
     } else {
         unset($this['user_id']);
     }
     $this->validatorSchema['edition_reason']->setOption('required', true)->setMessage('required', $this->required);
 }
 public function setup()
 {
     parent::setup();
     unset($this['id'], $this['is_active'], $this['is_delete'], $this['created_at'], $this['updated_at'], $this['edition_reason']);
     $this->widgetSchema['reply_author'] = new sfWidgetFormInputText(array(), array('readonly' => "readonly"));
     $this->widgetSchema->setLabel('reply_author', __('Reply to', array(), 'vjComment'));
     $this->widgetSchema->setHelp('author_email', __('Your email will never be published', array(), 'vjComment'));
     $this->widgetSchema['user_id'] = new sfWidgetFormInputHidden();
     if (vjComment::isUserBoundAndAuthenticated()) {
         unset($this['author_email'], $this['author_website'], $this['author_name']);
     } else {
         unset($this['user_id']);
     }
     if (vjComment::isCaptchaEnabled() && !vjComment::isUserBoundAndAuthenticated()) {
         $this->addCaptcha();
     }
 }
Example #3
0
  public function setup()
  {
    parent::setup();
    
    $user = $this->getOption('user');
    $fields = array(
      'record_model',
      'record_id',
      'author_name',
      'author_email',
      'author_website',
      'body',
      'reply'
    );
    if(vjComment::isGuardBindEnabled())
    {
      $fields[] = 'user_id';
    }
    $this->useFields($fields);
    
    $this->widgetSchema['reply_author'] = new sfWidgetFormInputText(array(), array('readonly' => "readonly"));
    $this->widgetSchema->setLabel('reply_author', __('Reply to', array(), 'vjComment'));
    $this->widgetSchema->setHelp('author_email', __('Your email will never be published', array(), 'vjComment'));
    $this->widgetSchema['user_id'] = new sfWidgetFormInputHidden();

    if( vjComment::isUserBoundAndAuthenticated($user) )
    {
        unset( $this['author_email'], $this['author_website'], $this['author_name'] );
    }
    else
    {
        unset( $this['user_id'] );
    }
    if (vjComment::isCaptchaEnabled() && !vjComment::isUserBoundAndAuthenticated($user) )
    {
      $this->addCaptcha();
    }
    $this->widgetSchema->setNameFormat($this->getOption('name').'[%s]');
  }