我正在尝试在symfony2中创建一个简单的博客。但不幸的是,我在尝试在symfony2中创建表单时遇到问题,代码位于
之下<?php
/**
* Created by PhpStorm.
* User: kanat
* Date: 2/13/16
* Time: 8:11 PM
*/
namespace Blogger\BlogBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class EnquiryType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name');
$builder->add('email', 'email');
$builder->add('subject');
$builder->add('body', 'textarea');
}
public function getName()
{
return 'contact';
}
}
位于Blogger \ BlogBundle \ Form \ EnquiryType.php中 错误是:
“string”类型的预期参数,&gt;“Blogger \ BlogBundle \ Form \ EnquiryType”给出
我不知道如何解决这个问题。请帮帮我
答案 0 :(得分:4)
您的版本,但错误:
$form = $this->createForm(EnquiryType::class, $yourEntity);
您必须使用:
public function contactAction() {
$enquiry = new Enquiry();
$form = $this->createForm(EnquiryType::class, $enquiry);
<强>控制器强>:
function myFunction(xml, player_name) {
var x, i, xmlDoc, notes;
xmlDoc = xml.responseXML;
x = xmlDoc.getElementsByTagName("Notepad");
for (i = 0; i < x.length; i++) {
if (x[i].getElementsByTagName("Name")[0].childNodes[i].nodeValue == player_name) {
notes = x[i].getElementsByTagName("Notes")[0].childNodes[i].nodeValue;
document.getElementById("something").innerHTML = notes;
}
}
}