我有一个带有动作上传和地图的控制器。如果用户成功上传文件,我会重定向用户 到地图行动。在此操作中,用户可以将文件映射到实体列。我的问题是“MapAction” 仅按字面意思呈现为响应
class ImportController
{
public function uploadAction(Request $request)
{
/** @TODO something **/
$fileName = 'test';
$params = ['fileName' => $fileName];
$form = $this->createForm(new UploadType());
if ($form->isValid()
{
return $this->redirect($this->generateUrl('import_map', $params));
}
return $this->render('AcmeAppBundle:Import:upload.html.twig', ['form' => $form->createView()]);
}
public function mapAction(Request $request, $fileName)
{
/** @TODO something **/
$form = $this->createForm(new MappingType());
// die("I reach this point successful");
// Render result
return $this->render('AcmeAppBundle:Import:mapping.html.twig', ['form' => $form->createView()]);
}
}
{% extends '::base.html.twig' %}
{% block content %}
{{ form_start(form, {'attr': {'novalidate': 'novalidate'}}) }}
{{ form_widget(form) }}
<button type="submit" class="btn btn-primary">{% trans %}upload{% endtrans %}</button>
{{ form_end(form) }}
{% endblock %}
import_map:
path: /import-map/{fileName}
defaults: { _controller: AcmeAppBundle:Import:map}
以下是我对import_map的路由:
public function actionCreate()
{
$model = new Employeeinformation();
if ($model->load(Yii::$app->request->post())){
$model->password = sha1($model->password);
$model->created_date = date('Y-m-d H:i:s');
if ($model->save())
return $this->redirect(['view', 'id' => $model->employee_id]);
}
return $this->render('create', [
'model' => $model,
]);
}
为什么会出现此问题?有人可以给我一个暗示吗?