我是 php 和 symfony2 的菜鸟。
我正尝试按照教程 http://symfony.com/doc/current/book/forms.html 创建一个表单和其他一些教程。
我收到“500 内部错误”,我不知道我什么时候失败了,我正在伤脑筋。需要帮助,请
日志:
[2015-10-16 23:35:27] request.INFO: Matched route "nueva_serie". {"route_parameters":{"_controller":"Acme\\AxialBundle\\Controller\\SeriesController::nuevaAction","_route":"nueva_serie"},"request_uri":"http://pruebas.com/nueva-serie/"} []
[2015-10-16 23:35:27] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2015-10-16 23:35:27] request.CRITICAL: Uncaught PHP Exception ReflectionException: "Class Acme\AxialBundle\Controller\Request does not exist" at /home/jjrojo/estigia/vendor/sensio/framework-extra-bundle/EventListener/ParamConverterListener.php line 83 {"exception":"[object] (ReflectionException(code: 0): Class Acme\\AxialBundle\\Controller\\Request does not exist at /home/jjrojo/estigia/vendor/sensio/framework-extra-bundle/EventListener/ParamConverterListener.php:83)"} []
[2015-10-16 23:35:27] request.INFO: Matched route "_wdt". {"route_parameters":{"_controller":"web_profiler.controller.profiler:toolbarAction","token":"884636","_route":"_wdt"},"request_uri":"http://pruebas.com/_wdt/884636"} []
路由.yml:
nueva_serie:
path: /nueva-serie/
defaults: { _controller: AcmeAxialBundle:Series:nueva}
这是我在 SeriesController 中的 Action Controller :
public function nuevaAction(Request $request)
{
$request = $this->getRequest();
$serie = new Serie();
$form = $this->createForm(new SerieType(), $serie);
if($request->getMethod() == 'POST')
{
$form->bindRequest($request);
if($form->isValid()){
//get data and flush
return $this->redirect($this->generateURL('lista'));
}
}
return $this->render('AcmeAxialBundle:Series:nueva.html.twig', array(
'form' => $form->createView(),
));
}
类型,SerieType.php:
<?php
namespace Acme\AxialBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class SerieType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('titulo')
->add('imagen')
->add('descripcion');
}
public function getName()
{
return 'form_serie';
}
}
和 nueva.html.twig
{% block body %}
<form action="{{ path('nueva_serie') }}" method="post">
{{ form_widget(form) }}
<input type="submit" />
</form>
{% endblock %}
感谢您的帮助。
最佳答案
您的文件缺少这个简单的使用语句:
使用 Symfony\Component\HttpFoundation\Request;
但是:当您在同一个函数中使用 $request = $this->getRequest() 时,通过该函数传递 Request 是没有意义的。这是多余的。所以你真的可以这样做:
public function nuevaAction()
{
$request = $this->getRequest();
...
关于php - "Request does not exist"创建表单 symfony2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33180477/
出于纯粹的兴趣,我很好奇如何按顺序创建PI,而不是在过程结果之后生成数字,而是让数字在过程本身生成时显示。如果是这种情况,那么数字可以自行产生,我可以对以前看到的数字实现垃圾收集,从而创建一个无限系列。结果只是在Pi系列之后每秒生成一个数字。这是我通过互联网筛选的结果:这是流行的计算机友好算法,类机器算法:defarccot(x,unity)xpow=unity/xn=1sign=1sum=0loopdoterm=xpow/nbreakifterm==0sum+=sign*(xpow/n)xpow/=x*xn+=2sign=-signendsumenddefcalc_pi(digits
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
如何使用RSpec::Core::RakeTask初始化RSpecRake任务?require'rspec/core/rake_task'RSpec::Core::RakeTask.newdo|t|#whatdoIputinhere?endInitialize函数记录在http://rubydoc.info/github/rspec/rspec-core/RSpec/Core/RakeTask#initialize-instance_method没有很好的记录;它只是说:-(RakeTask)initialize(*args,&task_block)AnewinstanceofRake
关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion为什么SecureRandom.uuid创建一个唯一的字符串?SecureRandom.uuid#=>"35cb4e30-54e1-49f9-b5ce-4134799eb2c0"SecureRandom.uuid方法创建的字符串从不重复?