我在使用带有url_for方法的对象时遇到了问题,我认为这个想法是自动找到任何需要的parapeters吗?
The "/publish/:id/:token" route has some missing mandatory parameters (:id, :token).
的routing.yml
post_publish:
url: /publish/:id/:token
options:
model: HookupPost
type: object
method_for_criteria: doSelectOneInactive
param: { module: post, action: show }
requirements:
id: \d+
token: \w+
sf_method: [GET]
newSuccess.php
<?php echo public_path(url_for("@post_publish", $post), true); ?>
操作传递$ post并包含最近创建的帖子!
有谁知道为什么会出现这种错误?我误解了什么吗?
谢谢,
答案 0 :(得分:2)
你错过了sfDoctrineRoute声明:
post_publish:
url: /publish/:id/:token
class: sfDoctrineRoute
options:
model: HookupPost
type: object
method_for_criteria: doSelectOneInactive
param: { module: post, action: show }
requirements:
id: \d+
token: \w+
sf_method: [GET]
然后你可以这样做:
<?php echo public_path(url_for("post_publish", $post), true); ?>
答案 1 :(得分:0)
尝试:
<?php echo public_path(url_for("post_publish",
array( 'id' => $post->id, 'token' => $post->token )), true); ?>
或类似的内容,具体取决于您的Post
课程。