我在symfony 2控制器中創建表單。Symfony 2表單處理請求未找到
這裏是什麼樣子:
$data = date('Y-m-d');
$time = date('H:i:s');
$form = $this->createFormBuilder()
->add('incident', 'entity', array('class' => 'MainCoreBundle:Incidenttype', 'multiple' => false, 'expanded' => true))
->add('date', 'text',array('data'=>$data))
->add('time', 'text',array('data'=>$time))
->getForm();
$form->handleRequest($request);
if ($form->isValid())
if ($request->getMethod() == "POST") {
$message = \Swift_Message::newInstance()
->setSubject('SUBJECT')
->setFrom('[email protected]')
->setTo('[email protected]')
->setBody(
$this->renderView(
'MainAdminBundle:Msg:index.html.twig'));
$this->get('mailer')->send($message);
return $this->indexAction($request);
}
,我想做出有一個形式:2路輸入: - 一個與當前時間 - 第二,當前的日期 - 第三,從實體成才(這將是選擇框)
然後點擊我想將它發送到郵件。
而且我的錯誤是:Call to undefined method Symfony\Component\Form\Form::handleRequest()
在處理它之前得到'echo get_class($ form);'的結果。 – Flosculus 2014-09-10 11:23:47
Symfony \ Component \ Form \ Form – Cre3k 2014-09-10 11:26:13
您正在使用哪個版本的Symfony? 2.2? – Flosculus 2014-09-10 11:28:10