我正在为我的sonata管理项目创建一个新的操作页面。我想创建一个上传文件的页面,但我希望这个页面与创建页面不同。我尝试更改configureRoutes
功能,我添加了' / upload / path就像在Sonata教程中一样,但是他们告诉我使用getRouterIdParameter()
并且我不想要/app/class/<ID>/upload
之类的东西{1}}。我只想要/app/class/upload
。
这可能吗?
答案 0 :(得分:0)
这就是为什么你应该把对象的ID放到你的路线上。
Option Explicit
Private Sub CommandButton1_Click()
Dim Rng As Range
Dim R As Long, Rl As Long ' last row
With Worksheets("Sheet1")
Rl = .Cells(.Rows.Count, "A").End(xlUp).Row
R = Application.Max(Rl - 9, 3)
' pick Top 10 Countries
Set Rng = Range(.Cells(R, "A"), .Cells(Rl, "C"))
Rng.Copy Destination:=.Cells(3, "E")
' pick remaining countries
If R > 3 Then
Set Rng = Range(.Cells(3, "A"), .Cells(R - 1, "C"))
Rng.Copy Destination:=.Cells(3, "I")
' write totals
Rl = .Cells(.Rows.Count, "I").End(xlUp).Row
Set Rng = Range(.Cells(3, "J"), .Cells(Rl, "J"))
Rl = Rl + 1
With .Cells(Rl, "I")
.Value = "Remaining"
.HorizontalAlignment = xlRight
.Font.Bold = True
End With
With .Cells(Rl, "J")
.Value = Application.Sum(Rng)
.HorizontalAlignment = xlCenter
.Font.Bold = True
End With
With .Cells(Rl, "K")
.Value = Application.Sum(Rng.Offset(0, 1))
.HorizontalAlignment = xlCenter
.Font.Bold = True
End With
End If
End With
End Sub
但是!如果您的操作不应该使用特定对象 - 您可以避免路线中的对象public function superAction(Request $request, $id = null)
{
try {
if ($id !== null) {
$yourObject = $this->admin->getObject($id);
}
} catch (NotFoundHttpException $e) {
error_log($e->getMessage());
}
//... your logic
}
。您还可以使用GET方法传递变量。尽可能多的你。
想象一下,您想要更新所有对象。然后,您可以创建$id
,然后添加此路线:
updateAllAction()
只要您的操作不关心特定对象,您就可以避免在您的uri中/**
* @param RouteCollection $collection
*/
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('updateAll', 'update/all');
}
。
希望它有所帮助。