Php 表格未提交-Symfony2
为什么我的symfony2表格不提交? 如果我按下提交按钮,什么也不会发生 我不想要默认的表单{{form(form)}}。 默认表单可以工作。 错误似乎在小树枝上Php 表格未提交-Symfony2,php,forms,symfony,Php,Forms,Symfony,为什么我的symfony2表格不提交? 如果我按下提交按钮,什么也不会发生 我不想要默认的表单{{form(form)}}。 默认表单可以工作。 错误似乎在小树枝上 {% extends '::base.html.twig' %} {% block stylesheets %} {{ parent() }} <link href="{{ asset('css/essensplan/show.css') }}" rel="stylesheet" /> <
{% extends '::base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<link href="{{ asset('css/essensplan/show.css') }}" rel="stylesheet" />
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
{% endblock %}
{% block body -%}
{{ form_start(form) }}
<h1>Speiseplan für KW {{ kw }}</h1>
<form action = "" method = "post">
<input type="submit" name="back" value="<" class="btn-lg btn-success"/>
<input type="submit" name="next" value=">" class="btn-lg btn-success" />
<input type="hidden" name="kw" value="{{ kw }}">
</form>
<div class="container-fluid">
<div class="tag col-xs-3">
<div class="wochentag">
Montag
</div>
<div class="hauptgericht">
<div class="h"><strong>Hauptgericht</strong></div>
<div class=""> {{ form_widget(form.montagHauptgericht) }}
</div>
</div>
<div class="nachtisch">
<div class="n"><strong>Nachtisch</strong></div>
<div class=""> {{ form_widget(form.montagNachtisch) }} </div>
</div>
</div>
</div>
{{ form_widget(form.Eintragen) }}
{{ form_end(form) }}
{% endblock %}
<?php
namespace Chris\TestBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Chris\TestBundle\Entity\KW;
use Chris\TestBundle\Form\KWType;
use Symfony\Component\HttpFoundation\Session\Session;
/**
* Admin controller.
*
*/
class AdminController extends Controller
{
/**
* Lists all KW entities.
*
*/
public function adminAction(Request $request)
{
$jahr = "2014";
$kw = "43";
// $_GET parameters
// Änderung
if ($request->get('next')){
$kw = (intval($request->get('kw'))+1) . "";
//var_dump($kw);
}
if ($request->get('back')){
$kw = (intval($request->get('kw'))-1) . "";
//var_dump($kw);
}
$form = $this->createFormBuilder()
->add('montagHauptgericht', 'text')
->add('montagNachtisch', 'text')
->add('Eintragen', 'submit')
->getForm();
$form->handleRequest($request);
// data is an array with "name", "email", and "message" keys
$data = $form->getData();
return $this->render('ChrisTestBundle:KW:admin.html.twig', array(
'form' => $form->createView(), 'kw' => $kw
));
}
}
{%extends'::base.html.twig%}
{%块样式表%}
{{parent()}}
{%endblock%}
{%块体-%}
{{form_start(form)}}
Speiseplan für KW{{KW}
蒙塔格
Hauptgericht
{{form_widget(form.montagHauptgericht)}
Nachtisch
{{form_widget(form.montagNachtisch)}
{{form_小部件(form.Eintragen)}
{{form_end(form)}}
{%endblock%}
您的标记中似乎有嵌套表单(第一个表单来自twig的{{form}}
第二个表单位于标记中。根据或不允许您嵌套表单
标记。这可能是表单未正确提交的原因