2010-09-27 5 views
0

widget InvalidArgumentException "attention" n'existe paswidget de Symfony InvalidArgumentException "attention" n'existe pas

Lorsque je retire "attention", "captcha" donne la même erreur. Aucun de ces champs n'est dans la base de données. J'ai eu ce travail plus tôt jusqu'à ce que j'ai essayé de passer une variable à la forme des actions. Je l'ai pris mais je reçois toujours une erreur

Des pensées sur ce que je fais mal? Merci:

forme de base:

abstract class BaseItemsForm extends BaseFormDoctrine 
{ 
    public function setup() 
    { 

    $this->widgetSchema->setNameFormat('items[%s]'); 

    $this->setWidgets(array(
     'city_id'   => new sfWidgetFormInputText(), 
     'state_id'  => new sfWidgetFormInputText(), 
     'item_id'   => new sfWidgetFormInputHidden(), 
     'name'   => new sfWidgetFormInputText(), 
     'address'   => new sfWidgetFormInputText(), 
     'city'   => new sfWidgetFormInputText(), 
     'state'   => new sfWidgetFormInputText(), 
     'zip'    => new sfWidgetFormInputText(), 
     'zip9'   => new sfWidgetFormInputText(), 
     'county'   => new sfWidgetFormInputText(), 
     'url'    => new sfWidgetFormInputText(), 
     'phone'   => new sfWidgetFormInputText(), 
     'fax'    => new sfWidgetFormInputText(), 
     'owner'   => new sfWidgetFormInputText(), 
     'title'   => new sfWidgetFormInputText(), 
     'gender'   => new sfWidgetFormInputText(), 
     'employee'  => new sfWidgetFormInputText(), 
     'sales'   => new sfWidgetFormInputText(), 
     'category_id'  => new sfWidgetFormInputText(), 
     'attention'  => new sfWidgetFormChoice(array(
    'choices' => Doctrine_Core::getTable('Items')->getAttn(), 
    'multiple' => false, 'expanded' => false)), 
     'captcha'   => new sfWidgetFormReCaptcha(array(
    'public_key' => '******' 
)), 
     'sic_description' => new sfWidgetFormInputText(), 
     'custom'   => new sfWidgetFormInputText(), 
     'added'   => new sfWidgetFormDateTime(), 
     'user_id'   => new sfWidgetFormInputText(), 
     'logo'   => new sfWidgetFormInputText(), 
     'approved'  => new sfWidgetFormInputText() 
    )); 




    $this->setValidators(array(
     'city_id'   => new sfValidatorInteger(), 
     'state_id'  => new sfValidatorInteger(), 
     'item_id'   => new sfValidatorChoice(array('choices' => array($this->getObject()->get('item_id')), 'empty_value' => $this->getObject()->get('item_id'), 'required' => false)), 
     'name'   => new sfValidatorString(array('max_length' => 255)), 
     'address'   => new sfValidatorString(array('max_length' => 255)), 
     'city'   => new sfValidatorString(array('max_length' => 64)), 
     'state'   => new sfValidatorString(array('max_length' => 2)), 
     'zip'    => new sfValidatorString(array('max_length' => 5)), 
     'zip9'   => new sfValidatorString(array('max_length' => 10)), 
     'county'   => new sfValidatorString(array('max_length' => 64)), 
     'url'    => new sfValidatorString(array('max_length' => 255, 'required' => false)), 
     'phone'   => new sfValidatorString(array('max_length' => 32)), 
     'fax'    => new sfValidatorString(array('max_length' => 32, 'required' => false)), 
     'owner'   => new sfValidatorString(array('max_length' => 128)), 
     'title'   => new sfValidatorString(array('max_length' => 128)), 
     'gender'   => new sfValidatorString(array('max_length' => 6)), 
     'employee'  => new sfValidatorString(array('max_length' => 6)), 
     'sales'   => new sfValidatorString(array('max_length' => 16)), 
     'category_id'  => new sfValidatorString(array('max_length' => 10)), 
     'attention'  => new sfValidatorString(array('max_length' => 50, 'required' => false)), 
     'captcha'   => new sfValidatorReCaptcha(array(
    'private_key' => '******' 
)), 
     'sic_description' => new sfValidatorString(array('max_length' => 128)), 
     'custom'   => new sfValidatorInteger(), 
     'added'   => new sfValidatorString(array('max_length' => 255)), 
     'user_id'   => new sfValidatorInteger(), 
     'logo'   => new sfValidatorString(array('max_length' => 50, 'required' => false)), 
     'approved'  => new sfValidatorInteger(array('required' => false)), 
    )); 



    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); 

    $this->setupInheritance(); 

    parent::setup(); 
    } 

    public function getModelName() 
    { 
    return 'Items'; 
    } 

} 

Formulaire

class ItemsUserForm extends BaseItemsForm 
{ 
    public function setUserId($id) 
    { 
    $this->getObject()->setUser_id($id); 
    } 
    public function configure() 
    { 
     unset(
     $this['zip9'], 
     $this['city_id'], $this['state_id'], 
     $this['county'], $this['url'], 
     $this['title'], $this['gender'], 
     $this['employee'], $this['sales'], 
     $this['custom'], 
     $this['added'], $this['user_id'], 
     $this['logo'] 
    ); 

    $this->widgetSchema->setLabels(array(
     'owner' => 'Your Name:*', 
     'phone' => 'Your Phone:*', 
     'fax' => 'Your Fax:*', 
     'name' => 'Business Name:*', 
     'address' => 'Business Address:*', 
     'city' => 'City:*', 
     'state' => 'State:*', 
     'zip' => 'Zipcode:*', 
     'category_id' => 'Category/Keyword:*', 
     'attention'  => 'Attention:*', 
     'sic_description' => 'Business Description Message:*', 
     'captcha' => 'Image Verification:*' 
    )); 
    } 

} 

action

public function executeNew(sfWebRequest $request) 
    { 
    $this->form = new itemsUserForm(); 
    } 

Répondre

0

Je trouve le problème. J'ai oublié de changer le formulaire dans executeCreate. J'ai changé la ligne pour refléter executeNew et maintenant son fonctionnement.

Questions connexes