0
我正在開發一個使用Symfony2和樹枝的應用程序。我想從模板提交一個值給控制器,這個值是使用模板中的Jquery函數設置的。我爲此使用了表單和隱藏類型字段。這是我的控制器代碼:表單提交中的HTTP狀態代碼Symfony2
public function testuaanotatuAction(Request $request)
{
$Interpretatzea = new Interpretatzea();
$Interpretatzea->setMarkagarriaInterpretatua($Markagarria);
$form = $this->createFormBuilder($Interpretatzea)
->add('MarkInterpretazioak', 'hidden')
->getForm();
$Erantzuna = $this->getRequest();
if ($Erantzuna->getMethod() == 'POST')
{
$form->bindRequest($Erantzuna);
if ($form->isValid())
{
return $this->redirect($this->generateUrl('AnotatzaileaAnotatzaileaBundle_FAQ'),
array('proba' => $form->get('MarkInterpretazioak')));
}
}
//Anotatzeko galderaren interfazeari deitu eta azpimarratu beharreko markagarriaren MarkIdent-a pasatu
return $this->render('AnotatzaileaAnotatzaileaBundle:Page:AnotatuInterpretazio.html.twig',
array('form' => $form->createView()));
}
public function FAQAction($proba)
{
return $this->render('AnotatzaileaAnotatzaileaBundle:Page:FAQ.html.twig',array('proba' => $proba));
}
,這是模板AnotatuInterpretazio.html.twig,我使用下一個jQuery函數值分配給隱藏字段的一部分:
<form action="{{ path('AnotatzaileaAnotatzaileaBundle_testuaanotatu') }}" method="post" {{ form_enctype(form) }} class="erreg">
{{ form_widget(form) }}
<input type="submit" value="Egina" />
</form>
<!-- <a href="{{ path('AnotatzaileaAnotatzaileaBundle_testuaanotatu') }}"><button id="Egina_Botoia">Egina</button></a><br /> -->
<script type='text/javascript'>
$("MatchedTag").click(function()
{
$(this).toggleClass("highlight");
var Erantzuna = this.id;
$('#hiddenval').val('this.id');//Assigning the value
});
</script>
瀏覽器顯示下一個錯誤:
The HTTP status code "Array" is not valid.
500 Internal Server Error - InvalidArgumentException
任何想法爲什麼會這樣?