InvalidArgumentException小部件“注意”不存在
当我删除“注意”时,“验证码”会出现同样的错误。这些字段中没有一个在数据库中。我之前有这个工作,直到我尝试将一个变量从动作传递给表单。我接受了,但我仍然收到错误
对我做错了什么的想法?感谢:
基本形式:
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';
}
}
表格
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:*'
));
}
}
动作
public function executeNew(sfWebRequest $request)
{
$this->form = new itemsUserForm();
}
答案 0 :(得分:0)
我发现了问题。
我忘了在executeCreate中更改表单。我更改了行以反映executeNew,现在它正在工作。