Symfony 4 Form Builder EntityType 查询所有位置但不是默认值

Symfony 4 Form Builder EntityType query all where in but not for default value

我在使用 EntityType 的表单生成器上遇到问题,我需要 return 来自数据库的所有活动记录(c.status = 活动)和一个非活动记录(c.id = 200)。

我是 symfony 新手

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('merchant_api_biller', EntityType::class, [
                'label' => 'Choose Api Provider',
                'placeholder' => 'Select Api Provider',
                'required' => false,
                'class' => MerchantApiBiller::class,
                'query_builder' => function (EntityRepository $entityRepository) {

                    return $entityRepository->createQueryBuilder('c')
                        ->andWhere('c.status = active WITH INACTIVE c.id = 200')
                        ->andWhere('c.accountMode = :mode')
                        ->setParameter('mode', 'live')
                        ->addOrderBy('c.name', 'ASC');
                },
                'choice_label' => function (MerchantApiBiller $biller, $key, $index) {
                    // Hold Merchant Provider
                    $provider = ($biller->getMerchantApiProvider()) ? ' | '.$biller->getMerchantApiProvider()->getName() : null;

                    return ''.$biller->getName().' - '.$biller->getCurrecyName().''.$provider.'';
                },
                'choice_value' => 'identify',
                'choice_attr' => function (MerchantApiBiller $biller, $key, $index) {
                    return [
                        'data-name' => $biller->getName(),
                        'data-currencyid' => $biller->getCurrency()->getId(),
                        'data-hasamountfixed' => ($biller->getIsAmountFixed() == true) ? 1 : 0,
                        'data-minamount' => $biller->getMinAmount(),
                        'data-maxamount' => $biller->getMaxAmount(),
                        'data-hasdenomination' => ($biller->getDenomination()) ? 1 : 0,
                        'data-denomination' => ($biller->getDenomination()) ? implode(',', $biller->getDenomination()) : null,
                        'data-desc' => $biller->getDescription(),
                    ];
                },
            ]);

我需要 return 的所有记录 c.id = 200(其非活动记录),其他非活动记录保持非活动状态不显示在结果中。

谢谢

尝试更改此行:

->andWhere('c.status = active WITH INACTIVE c.id = 200')

为此:

->andWhere('c.status = active OR c.id = 200')