【问题标题】:The options "choices", "multiple" do not exist选项“选择”、“多个”不存在
【发布时间】:2019-05-29 05:21:39
【问题描述】:

我正在编辑 Sonata 生成的管理类。它处理基于计划和已完成分发的视频过滤。该类已经包含以下内容:

protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
    $datagridMapper
        ->add('producedTill', 'doctrine_orm_date', [], 'sonata_type_datetime_picker',
            $this->getDatePickerDefinitions(2, true, 3))
        ->add('plannedDistributions', null, [], null,
            $this->getEntityDefinitions('AppBundle:DistributionChannel', 1, true, 4))
}

... 这为我提供了一个不错的 UI,其中包括我的应用程序中“计划分发”字段的下拉列表。

现在我想为已完成的分发添加另一个下拉列表。我添加以下内容:

        ->add('distributions', null, [], null,
            $this->getEntityDefinitions('AppBundle:DistributionChannel', 1, true, 4))

...但是在重新加载列表视图时,我收到以下消息:

选项“选择”、“多个”不存在。定义的选项是: “动作”、“allow_extra_fields”、“attr”、“auto_initialize”、 “block_name”、“by_reference”、“cascade_validation”、“compound”、 “约束”、“csrf_field_name”、“csrf_message”、“csrf_protection”、 “csrf_provider”、“csrf_token_id”、“csrf_token_manager”、“数据”、 “data_class”、“description”、“disabled”、“empty_data”、 “error_bubbling”、“error_mapping”、“extra_fields_message”、 “horizo​​ntal_input_wrapper_class”,“horizo​​ntal_label_class”, “horizo​​ntal_label_offset_class”、“inherit_data”、“意图”、 “无效消息”、“无效消息参数”、“标签”、 “label_attr”、“label_format”、“label_render”、“mapped”、“max_length”、 “方法”、“模式”、“post_max_size_message”、“property_path”、 “只读”、“必需”、“奏鸣曲管理员”、“奏鸣曲字段描述”、 “奏鸣曲帮助”,“翻译域”,“修剪”, “upload_max_size_message”、“validation_groups”、“虚拟”。

我不相信我试图在我的 configureDatagridFilters 方法中定义任何“选择”或“多个”选项。这里会发生什么?

【问题讨论】:

    标签: php symfony sonata


    【解决方案1】:

    这很简单——getEntityDefinitions() 方法包含对这些字段的引用。

    public function getEntityDefinitions($entityName, $innerSort = null, $extended = false, $sort = 1)
    {
        return array(
            'choices' => $this->entityManager->getRepository($entityName)->getSortedElements($this->getLocale()),
            'multiple' => true,
            'attr' => array(
                'data-extended' => $extended,
                'data-sort' => $sort,
                'data-inner-sort' => $innerSort
            )
        );
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-24
      • 2022-07-16
      • 2013-09-16
      • 2019-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-23
      相关资源
      最近更新 更多