【发布时间】:2015-11-05 11:31:32
【问题描述】:
你能帮我吗?我找不到解决办法
<?php
/**
* Description of ContactType
*
* @author Thamer
*/
namespace Common\ContactBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Collection;
class ContactType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('name', 'text', array(
'constraints' => array(
new Length(array('min' => 3)),
new NotBlank()
)
)
)
->add('email', 'email', array(
new NotBlank()
)
)
->add('tel', 'number', array(
'constraints' => array(
new Length(array('min' => 8)),
new NotBlank()
)
)
)
->add('message', 'textarea', array(
'constraints' => array(
new Length(array('min' => 10)),
new NotBlank()
)
)
)
->add('recaptcha', 'ewz_recaptcha')
;
}
public function getName() {
return 'common_contact';
}
}
错误是:
选项“0”不存在。定义的选项是:“动作”, “allow_extra_fields”、“attr”、“auto_initialize”、“block_name”、 “by_reference”、“cascade_validation”、“compound”、“constraints”、 “csrf_field_name”、“csrf_message”、“csrf_protection”、“csrf_provider”、 “csrf_token_id”、“csrf_token_manager”、“数据”、“data_class”、 “已禁用”、“empty_data”、“error_bubbling”、“error_mapping”、 “extra_fields_message”、“inherit_data”、“意图”、 “无效消息”、“无效消息参数”、“标签”、 “label_attr”、“label_format”、“mapped”、“max_length”、“method”、 “模式”、“post_max_size_message”、“property_path”、“read_only”、 “必需”、“translation_domain”、“trim”、“validation_groups”、 “虚拟的”。 500 内部服务器错误 - UndefinedOptionsException
【问题讨论】:
-
在
$options参数中设置不被接受的key时经常发生。你用它做了什么吗?
标签: validation symfony