gpt4 book ai didi

php - symfony 2 表单字符串缺少第一个字符

转载 作者:搜寻专家 更新时间:2023-10-31 21:10:27 25 4
gpt4 key购买 nike

我有一个使用 symfony 2.2 的应用程序,它有一个文件上传表单和另一个“reportbuilder”表单。

我遇到的问题是,当我的任何输入字段值以“c”开头时,该字母将被删除。因此,如果提交的字段值为'cat',则绑定(bind)后的值将变为'at'。

  • 这似乎只出现在以“c”开头的字符串中
  • 这个问题发生在我的任何表单上的任何字符串上
  • 问题发生在 $form->bind() 方法期间(或其中的某处 - 我已经验证到那时发布变量是正确的)
  • 这个问题出现在我的 PREPROD 盒子上,但不是我的 DEV 盒子(环境应该相同,没有进行广泛的比较以大海捞针......两个 Redhat 安装)

根据我所做的一些搜索,我怀疑它可能与字符编码有关(我试图在环境之间进行比较),但我有点不知所措。

如果有帮助,我可以提供一些代码,但由于问题只发生在一台服务器上,而不是另一台服务器上,我不确定 symfony 代码中的哪一个(如果有的话)会有帮助。

这是否是菜鸟编码疏忽之类的问题?

编辑: 任何数量的前导“c”都会发生这种情况,因此“cat”、“ccat”和“Ccccccat”都将转换为“at”/p>

Edit2: 我可以在绑定(bind)后从 post 变量手动设置文本字段作为解决方法( $document->setName($postvars['name' ]))。 “Reportbuilder”表单的问题更大,它有可变数量的嵌套表单(报告有一个或多个选项卡,选项卡有一个或多个额外的列,等等)——所以类似的解决方法很笨拙而且不理想

Edit3:添加代码

class DefaultController extends Controller
{

public function indexAction()
{
...
$document = new Document();

$form = $this->createForm(new DocumentType($em,$user), $document);

/// Here the name variable in the request is 'cat', as expected
$form->bind($this->getRequest());
/// Here the value of the 'name' parameter in the form is 'at'

...

}
}

文档.orm.yml:

Finance\GstBundle\Entity\Document:
type: entity
manyToOne:
report:
targetEntity: Report
mappedBy: report
user:
targetEntity: Finance\UserBundle\Entity\User
mappedBy: user
oneToMany:
doctabs:
targetEntity: Doctab
mappedBy: document
tabgroups:
targetEntity: Tabgroup
mappedBy: document
table: document
fields:
id:
type: integer
id: true
generator:
strategy: AUTO
name:
type: string
length: 255
nullable: true
path:
type: string
length: 255

...和 ​​DocumentType 定义:

namespace Finance\GstBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class DocumentType extends AbstractType
{
protected $em;
protected $user;

public function __construct($em=null,$user=null){
$this->em = $em;
$this->user = $user;
}

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



$builder
->add('report','entity',array(
'class' => 'FinanceGstBundle:Report',
'property'=>'name',
'empty_value' => '--Choose a Template--'
))
->add('name')
->add('file')
;
}

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Finance\GstBundle\Entity\Document'
));
}

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

最佳答案

在所有 3 个 (dev/pre/prod) 机器上修补 RHEL 后,问题自行解决。我正在进行事后分析,以尝试确定导致我们遇到的错误的特定程序包。

我们的 RHEL 版本在不同的服务器上处于不同的“状态”。 PRE/PROD 在系统补丁方面远远落后于 Dev。

关于php - symfony 2 表单字符串缺少第一个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21099784/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com