RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-205440

Вадим Бондаренко's questions

Martin Hope
Вадим Бондаренко
Asked: 2020-08-21 18:24:00 +0000 UTC

表单不验证

  • 1

我遇到了表单没有通过验证的问题,无论值是否正确传递。此外,这只发生在一个skuBrand字段上。

我还从实体中删除了所有验证断言。我不明白为什么$form->isValid() = false方法。解析请求。它有一个值(对象Id)并且该对象在数据库中。{{ form_errors(form) }}变量不显示错误。

你怎么能理解为什么表单没有通过验证?

代码:表单类

class FiltersType extends AbstractType
{
    protected $securityContext;

    public function buildForm(FormBuilderInterface $builder, array $options)
    {

        $formOptions = $this->getFormOption('barcodeConsumer', array(  'required' => false,  'label' => 'fields.skuGlobal.barcodeConsumer',  'translation_domain' => 'Admin',));
        $builder->add('barcodeConsumer', 'text', $formOptions);


        $formOptions = $this->getFormOption('barcodeLogistics', array(  'required' => false,  'label' => 'fields.skuGlobal.barcodeLogistics',  'translation_domain' => 'Admin',));
        $builder->add('barcodeLogistics', 'text', $formOptions);


        $formOptions = $this->getFormOption('name', array(  'required' => false,  'label' => 'fields.skuGlobal.name',  'translation_domain' => 'Admin',));
        $builder->add('name', 'text', $formOptions);


        $formOptions = $this->getFormOption('nameShort', array(  'required' => false,  'label' => 'fields.skuGlobal.nameShort',  'translation_domain' => 'Admin',));
        $builder->add('nameShort', 'text', $formOptions);


        $formOptions = $this->getFormOption('skuCategory', array(  'multiple' => false,  'em' => 'default',  'class' => 'Nitra\\SchemaCDBBundle\\Entity\\SkuCategory',  'required' => false,  'group_by' => 'skuGroup.name',  'label' => 'fields.skuGlobal.skuCategory',  'translation_domain' => 'Admin',));
        $builder->add('skuCategory', 'entity', $formOptions);


        $formOptions = $this->getFormOption('skuBrand', array(  'multiple' => false,  'em' => 'default',  'class' => 'Nitra\\SchemaCDBBundle\\Entity\\SkuBrand',  'required' => false,  'label' => 'fields.skuGlobal.skuBrand',  'translation_domain' => 'Admin',));
        $builder->add('skuBrand', 'entity', $formOptions);


        $formOptions = $this->getFormOption('skuType', array(  'multiple' => false,  'em' => 'default',  'class' => 'Nitra\\SchemaCDBBundle\\Entity\\SkuType',  'required' => false,  'label' => 'fields.skuGlobal.skuType',  'translation_domain' => 'Admin',));
        $builder->add('skuType', 'entity', $formOptions);


        $formOptions = $this->getFormOption('externalKey1', array(  'required' => false,  'label' => 'fields.skuGlobal.externalKey1',  'translation_domain' => 'Admin',));
        $builder->add('externalKey1', 'text', $formOptions);


        $formOptions = $this->getFormOption('externalKey2', array(  'required' => false,  'label' => 'fields.skuGlobal.externalKey2',  'translation_domain' => 'Admin',));
        $builder->add('externalKey2', 'text', $formOptions);


        $formOptions = $this->getFormOption('status', array(  'required' => false,  'choices' =>   array(    0 => 'Нет',    1 => 'Да',  ),  'empty_value' => '',  'label' => 'fields.skuGlobal.status',  'translation_domain' => 'Admin',));
        $builder->add('status', 'choice', $formOptions);


    }

    protected function getFormOption($name, array $formOptions)
    {
        return $formOptions;
    }

    public function getName()
    {
        return 'filters_skuglobal';
    }

    public function setSecurityContext($securityContext)
    {
        $this->securityContext = $securityContext;
    }

}

SkuGlobal的精髓

    class SkuGlobal extends BaseEntity {

    use \Nitra\SchemaCDBBundle\Model\TranslatableEx;

    public function __toString() {
        return (string) $this->translate()->getName();
    }
     /**
     * Бренд СКЮ
     * @ORM\ManyToOne(targetEntity="SkuBrand", inversedBy="skuGlobals")
     */
    protected $skuBrand;
}

SKU_品牌实体。

class SkuBrand extends BaseEntity
{

    use \Nitra\SchemaCDBBundle\Model\TranslatableEx;

    public function __toString()
    {
        return (string) $this->translate()->getName();
    }

     /**
     * Глобальные СКЮ привязанные к бренду
     *
     * @ORM\OneToMany(targetEntity="SkuGlobal", mappedBy="skuBrand")
     */
    protected $skuGlobals;

    /**
     * Constructor
     */
    public function __construct()
    {
        parent::__construct();
        $this->skuGlobals = new \Doctrine\Common\Collections\ArrayCollection();
        $this->target = new \Doctrine\Common\Collections\ArrayCollection();
        $this->promotionSkuListDetail = new \Doctrine\Common\Collections\ArrayCollection();
        $this->updateTranslations();
    }
}
form
  • 1 个回答
  • 10 Views
Martin Hope
Вадим Бондаренко
Asked: 2020-04-18 20:25:30 +0000 UTC

symfony 处理文件

  • 0

文件处理是如何在 siphon 中实现的?例如,我有一个静态文件,我想让它可供下载。我需要如何在 Twig 模板引擎中为其生成路径。我知道有一个资产,但据我了解,它定位于 CSS、JS 和图像文件。

symfony2
  • 1 个回答
  • 10 Views
Martin Hope
Вадим Бондаренко
Asked: 2020-04-04 17:15:13 +0000 UTC

交响乐形式。既不是属性“TM”,也不是其中一种方法

  • 0

构建表单时发生错误。

Neither the property "TM" nor one of the methods "getTM()", "isTM()", "hasTM()", "__get()" exist and have public access in class "Nitra\SchemaCDBBundle\Entity\MonthPlan.

错误在于它FormBuilder没有在 MonthPlan 实体类中找到任何方法或 TM 属性。但是我不明白他为什么要在 MonthPlan 实体中寻找这个方法。

我有一个班级MonthPlan,与员工的关系表示班级Employee

  /**
 * Сотрудник
 *
 * @ORM\ManyToOne(targetEntity="Employee", inversedBy="monthPlans")
 * @Assert\Type(type="Nitra\SchemaCDBBundle\Entity\Employee")
 */
protected $employee;

我需要为班级MonthPlan中的某些员工创建一个表格Employee。为此,我创建了一个类Form并声明了buildForm. 正如您在上次调用中看到的那样$builder->add(),我指定了选择员工所依据的类和查询以及显示结果所依据的属性'property' =>'name',但最后我得到了上面指出的错误。

 public function buildForm(FormBuilderInterface $builder, array $options)
{
    parent::buildForm($builder, $options);

    $builder->add('chosenType', 'choice', array(
        'required' => true,
        'mapped' => false,
        'choices' => array(
            4 => 'fields.month.eta',
            2 => 'fields.month.TM'
        ),
        'label' => 'fields.month.typeEmployee',
        'translation_domain' => 'Admin'));

    $builder->add('TM', 'entity', array(
        'multiple' => false,
        'em' => 'default',
        'class' => 'NitraSchemaCDBBundle:Employee',
        'required' => false,
        'label' => 'fields.monthPlan.tm',
        'translation_domain' => 'Admin',
        'query_builder' => function(EntityRepository $er){
            return $er->createQueryBuilder('u')
                ->andWhere('u.lvl = :lvl')
                ->setParameter('lvl',2)
                ->addOrderBy('u.sureName','ASC');
        },
        'property' =>'name',
    ));

创建表单的完整代码。有一个父类EditType,里面是根据yml文件生成的。我继承并覆盖它buildForm

namespace Admingenerated\NitraEmployeeBundle\Form\BaseMonthPlanType;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use JMS\SecurityExtraBundle\Security\Authorization\Expression\Expression;

class EditType extends AbstractType
{
    protected $securityContext;

    public function buildForm(FormBuilderInterface $builder, array $options)
    {

        $formOptions = $this->getFormOption('year', array(  'required' => true,  'mapped' => true,  'label' => 'fields.target.choseYear',  'translation_domain' => 'Admin',));
        $builder->add('year', new \Nitra\CommonBundle\Form\YearType(), $formOptions);


        $formOptions = $this->getFormOption('month', array(  'required' => true,  'mapped' => true,  'label' => 'fields.target.choseMonth',  'translation_domain' => 'Admin',));
        $builder->add('month', new \Nitra\CommonBundle\Form\MonthType(), $formOptions);


        $formOptions = $this->getFormOption('target', array(  'multiple' => false,  'em' => 'default',  'class' => 'Nitra\\SchemaCDBBundle\\Entity\\Target',  'required' => false,  'label' => 'fields.monthPlan.target',  'translation_domain' => 'Admin',));
        $builder->add('target', 'entity', $formOptions);


        $formOptions = $this->getFormOption('employee', array(  'multiple' => false,  'em' => 'default',  'class' => 'Nitra\\SchemaCDBBundle\\Entity\\Employee',  'required' => true,  'label' => 'fields.monthPlan.employee',  'translation_domain' => 'Admin',));
        $builder->add('employee', 'entity', $formOptions);


        $formOptions = $this->getFormOption('summ', array(  'precision' => 12,  'required' => true,  'label' => 'fields.monthPlan.summ',  'translation_domain' => 'Admin',));
        $builder->add('summ', 'number', $formOptions);


    }

    protected function getFormOption($name, array $formOptions)
    {
        return $formOptions;
    }

    public function getName()
    {
        return 'edit_monthplan';
    }

    public function setSecurityContext($securityContext)
    {
        $this->securityContext = $securityContext;
    }

}

我的自定义表单构建类。

namespace Nitra\EmployeeBundle\Form\Type\MonthPlan;

use Admingenerated\NitraEmployeeBundle\Form\BaseMonthPlanType\EditType as BaseEditType;
use Nitra\SchemaCDBBundle\Repository\EmployeeRepository;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\EntityRepository;
use Nitra\SchemaCDBBundle\Entity\Employee;
use Nitra\CommonBundle\Form\MonthType;
use Nitra\CommonBundle\Form\YearType;

class EditType extends BaseEditType {

    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $builder->add('chosenType', 'choice', array(
            'required' => true,
            'mapped' => false,
            'choices' => array(
                4 => 'fields.month.eta',
                2 => 'fields.month.TM'
            ),
            'label' => 'fields.month.typeEmployee',
            'translation_domain' => 'Admin'));

        $builder->add('TM', 'entity', array(
            'multiple' => false,
            'em' => 'default',
            'class' => 'NitraSchemaCDBBundle:Employee',
            'required' => false,
            'label' => 'fields.monthPlan.tm',
            'translation_domain' => 'Admin',
            'query_builder' => function(EntityRepository $er){
                return $er->createQueryBuilder('u')
                    ->andWhere('u.lvl = :lvl')
                    ->setParameter('lvl',2)
                    ->addOrderBy('u.sureName','ASC');
            },
            'property' =>'name',
        ));
    }

    protected function getFormOption($name, array $formOptions) {
        switch ($name) {
            case 'employee':
                $formOptions['query_builder'] = function (EmployeeRepository $er) {
                            return $er->getEmployeeAtPositionEta($this->securityContext->getToken()->getUser());
                        };
                break;
        }
        return $formOptions;
    }

}
symfony2
  • 1 个回答
  • 10 Views
Martin Hope
Вадим Бондаренко
Asked: 2020-03-24 04:38:17 +0000 UTC

仅更新特定视图的缓存

  • 2

我有一个相当大的 symfony 项目和 2 个测试和生产服务器。所以,所有的开发都是在测试服务器上进行的,当任务与FrontEnd相关时,缓存的长期更新就出现了问题。这个过程最多需要 5 分钟,这大大增加了工作的复杂性。

是否可以以某种方式仅针对特定 URL 而不是整个项目更新缓存?

php
  • 1 个回答
  • 10 Views
Martin Hope
Вадим Бондаренко
Asked: 2020-09-06 16:54:43 +0000 UTC

形成对 MS SQL 的查询 - 数据类型转换错误

  • 0

对MS SQL 进行查询时,数据类型转换出错。character string to uniqueidentifier 我试图对数据库进行查询,但出现错误。我按照指示做所有事情。

错误:

SQLSTATE[42000]:[Microsoft][SQL Server 的 ODBC 驱动程序 11][SQL Server]从字符串转换为唯一标识符时转换失败

请求代码:

$queryValueData = 'SELECT ETA_Employee_id as eta_id, GroupSort as gs, MeasureName as mn, MeasureSort as ms, Value as value
    FROM
        EO_TS
    WHERE 
        TS_employee_id IN (:ids)
        AND Date BETWEEN :ds AND :df
        AND TableName = :tableName
    ORDER BY
        ETA_Employee_id, GroupSort, MeasureSort';

$valueData = $conn->executeQuery(
    $queryValueData,
    array(
        'ids' =>$tsIds,
        'ds' => $date->format('Y-m-d 00:00:00.000000 +02:00'),
        'df' => $date->format('Y-m-d 23:59:59.000000 +02:00'),
        'tableName' => $tableName,
    ),
    array(\Doctrine\DBAL\Connection::PARAM_STR_ARRAY)
);

如果要传输而不是IN一个值,则请求成功完成。我也试过通过参数指定类型,同样没有得到结果。更改了下一个值

\Doctrine\DBAL\Connection::PARAM_STR_ARRAY

在

$type = \Doctrine\DBAL\Types\Type::getType('guid');

链接到类型及其映射的描述。

$tsIds 数组以下列格式存储数据:

83176DA0-C808-48D7-B802-3A2ADE61740A

php
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5