Tôi vừa cập nhật symfony từ 2.7 lên 3.0 và gặp một số rắc rối với nó ..Symfony 3 - Không thể tải loại biểu mẫu loại
Nó không thể tải loại biểu mẫu của tôi. Đây là một ví dụ.
services.xml
app.search:
class: AppBundle\Form\Type\SearchFormType
tags:
- { name: form.type, alias: app_search }
Thats cách im cố gắng để tạo ra hình thức.
$form = $this->createForm('app_search', new Search());
SearchFormType
namespace AppBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class SearchFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('phrase', 'text');
}
public function getBlockPrefix()
{
return 'app_search';
}
}
Bắt lỗi tiếp theo:
An exception has been thrown during the rendering of a template ("Could not load type "app_search"") in ....
Làm thế nào nó sẽ giống như trong symfony 3.0?
Cảm ơn!
Tôi biết điều đó nghe có vẻ khó hiểu nhưng nơi đầu tiên để xem là tài liệu: http://symfony.com/doc/current/book/forms.html#building-the-form. Bạn sẽ nhận thấy rằng các bí danh của biểu mẫu như 'văn bản' đã biến mất. Điều này cũng được đề cập trong tệp nâng cấp. Cũng như một vài chục câu hỏi stackoverflow gần đây. – Cerad