我有一个使用symfony 2.2的应用程序,该应用程序具有文件上传表单和另一个“ reportbuilder”表单。
我遇到的问题是,当我的任何输入字段值以'c'开头时,该字母都会被删除。因此,如果提交的字段值为“ cat”,则绑定后的值将变为“ at”。
根据我所做的一些搜索,我怀疑它可能与字符编码有关(我曾尝试在各种环境之间进行比较),但我有些茫然。
如果有帮助,我可以提供一些代码,尽管由于问题仅发生在一台服务器上而不是另一台服务器上,所以我不确定symfony代码中的哪一个(如果有)会有所帮助。
有没有作为新手编码监督之类的东西脱颖而出?
编辑: 这发生在任何数量的前导“ c”中,因此“ cat”和“ ccat”以及“ Ccccccat”都将转换为“ at”
Edit2: 绑定后,我可以通过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'
...
}
}
document.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。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句