tags:

views:

22

answers:

1

InvalidArgumentException widget "attention" does not exist

When I remove "attention", "captcha" gives the same error. Neither one of these fields are in the database. I had this working earlier until I tried to pass a variable to the form from actions. I took that out but I'm still getting an error

Any thoughts on what I'm doing wrong? Thanks:

Base form:

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';
  }

}

Form

    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();
  }
A: 

I found the problem.

I forget to change the form in executeCreate. I changed the line to reflect executeNew and now its working.

Ite Code