php - Cannot read index "type" from object of type "stdClass" because it doesn't implement \ArrayAccess
问题描述
I am getting this error on this
if ($this->container->getParameter('sso.so') === true) {
$builder->add('familyMembers', CollectionType::class, array(
'type' => new FamilyMember(),
'allow_add' => TRUE,
'allow_delete' => TRUE,
'by_reference' => FALSE,
));
$builder->get('familyMembers')->setData(array());
}
this is the form Type
class FamilyMember extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('type', ChoiceType::class, array(
'label' => ' ',
'required' => FALSE,
'choices' => array(
'SP' => 'account.address.option.type.SP',
'DP' => 'account.address.option.type.DP',
),
'expanded' => TRUE,
'multiple' => FALSE,
'placeholder' => FALSE,
))
what I am trying to do is allow the form to be created if they meet that condition.
this worked but i updated to symfony2.8 and I also went from guzzle3 to guzzle 6 (doubt is this one)
解决方案
根据从 Symfony 2.8 开始的文档, entry_type替换了type。
$builder->add('familyMembers', CollectionType::class, array(
'entry_type' => new FamilyMember(),
'allow_add' => TRUE,
'allow_delete' => TRUE,
'by_reference' => FALSE,
));
推荐阅读
- postgresql - jooq - 识别 postgres UNIQUE 约束的问题
- assembly - 在Assembly中同时生成2个随机整数
- android - 如何为finish()和onBackPressed实现相同的动画?
- stream - 有没有办法从 mpv 播放器的播放直接流式传输到网络?
- javascript - 基于RequiredFieldValidators 防止多次保存点击
- reactjs - 将 SlateJs 转换为 pdf 的最佳方法
- javascript - 如何计算元素的比例,并将值转换为光标所在的点?
- java - Volley 应为 BEGIN_ARRAY,但在第 1 行第 2 列路径为 BEGIN_OBJECT
- regex - 如何编写与子字符串不匹配并以字符串结尾的正则表达式?
- jaeger - OpenTracing + Jaeger:未报告 SQL 跟踪