我在同一页面上有两个表单.
我的问题是当我尝试提交表单时,就像它尝试在页面中提交下面的第二个表单一样.
如下,你可以找到我的2个表格:
public function createSuiviForm() {
return $form = $this->createFormBuilder(null)
->add('numero', 'text', array('label' => 'N° : ',
'constraints' => array(
new Assert\NotBlank(array('message' => 'XXXX')),
new Assert\Length(array('min' => 19, 'max' => 19, 'exactMessage' => 'XXX {{ limit }} XXX')))))
->add('xxxx', 'submit')
->getForm();
}
public function createModificationForm() {
return $form = $this->createFormBuilder(null)
->add('modification', 'submit', array('label' => 'XXXXXXXXXXXXXXXXXXXX'))
->getForm();
}
Run Code Online (Sandbox Code Playgroud)
我的第二个表单只是一个提交按钮.
我将它们传递给我的渲染并使用以下方式显示它们:
<div class="well">
<form method="post" action='' {{form_enctype(form)}} >
{{ form_widget(form) }}
<input type="submit" class="btn btn-primary"/>
</form>
<div class='errors'>
{{ form_errors(form) }} …Run Code Online (Sandbox Code Playgroud) 我需要你的帮助来使用Doctrine构建我的查询.我是一个symfony初学者.首先,我在MySQL SQL选项卡中构建了我的查询,它工作正常.
SELECT *
FROM contact
WHERE insee like '03%'
ORDER BY (LENGTH(tif) - LENGTH(REPLACE(tif,";",""))) DESC
To be more precise, my tif field looks like that :
1 - 01.02.01.02;01.02.03.04;01.05.06 (3 subsets)
2 - 01.02.03.08.07.01.02.03.08.0701.02.03.08.07; (1 subset)
3 - 01.02.01;02.06.05 (2 subsets)
Run Code Online (Sandbox Code Playgroud)
我需要通过desc获取代码的数量,以获得订单1,3,2.
现在我尝试在Symfony的我的存储库类中构建它我发现在Doctrine上不存在替换函数所以我试图通过执行以下操作来绕过它:
$qb = $this->getEntityManager()
->createQueryBuilder()
->select('c')
->from('SgaContactBundle:Contact', 'c')
->where('c.insee LIKE :insee')
->setParameter('insee', '%' . $insee . '%');
$qb->orderBy($qb->expr()->diff(
$qb->expr()->length('c.tif'),
$qb->expr()->length(preg_match_all('/;/i', 'c.tif')) ),
'DESC');
return $qb->getQuery()
->getResult();
Run Code Online (Sandbox Code Playgroud)
最后我有这个错误:
[Syntax Error] line 0, col 99: Error: Expected StateFieldPathExpression | …Run Code Online (Sandbox Code Playgroud) 我需要实现分页.看来,Doctrine并不支持某些联合会.
这是我的查询:
$query = $this->getEntityManager()
->createQueryBuilder();
$query->setFirstResult(($page - 1) * $maxperpage);
$query->setMaxResults($maxperpage);
$query->select('d')
->from('DemandeBundle:Declaration', 'd')
->orderBy('d.id', 'ASC')
->innerJoin('ContactBundle:Contact', 'c', 'WITH', 'd.contact = c')
->where('c.structure_id = :structure_id')
->setParameter('structure_id', $structureId)
->getQuery()
->getResult();
return new Paginator($query, true);
Run Code Online (Sandbox Code Playgroud)
当我不使用innerJoin时,它工作正常,但我需要使用它,以便只显示有关我的用户的请求.
使用innerJoin我遇到了这样的错误:
"An exception has been thrown during the rendering of a template
("Cannot count query which selects two FROM components, cannot make distinction") in
DemandeBundle:Demande:listing_demande.html.twig at line 25"
Run Code Online (Sandbox Code Playgroud)
如何在不使用其他捆绑或其他任何东西的情况下绕过这个问题.
希望你能理解我的家伙.