我精简了FileUploadForm,这给我带来了麻烦。
routing.yml如下所示:
FileUpload.FileUploadForm:
path: '/file/upload/'
defaults:
_form: '\Drupal\FileUpload\Form\FileUploadForm'
_title: 'File Upload'
requirements:
_permission: 'access content'
FileUpload.ServeFile:
path: '/file/serve/{file_id}'
defaults:
_controller: '\Drupal\FileUpload\Controller\FileUploadController::serve'
_title: 'File Download'
requirements:
_permission: 'access content'
这是我现在的FileUploadForm:
<?php
namespace Drupal\FileUpload\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class FileUploadForm extends FormBase {
public function getFormId() {
return 'fileupload_fileuploadform';
}
public function buildForm(array $form, FormStateInterface $form_state) {
return $form;
}
public function validateForm(array &$form, FormStateInterface $form_state) {
}
public function submitForm(array &$form, FormStateInterface $form_state) {
}
}
?>
该表单位于src / Form目录中,而Controller位于src / Controller中。我仔细检查了文件名。当我仅包含控制器时,以上方法就可以工作,但是一旦添加(甚至为空)Form,刷新缓存时就会收到错误消息,但是日志中什么也没有显示。
必须要有某种形式,知道它可能是什么?