开发者

Redirect back to list on syfmony generated form?

I've generated an admin section with Propel on syfmony. When I have added an item I wish it to redirect back to th开发者_运维问答e list, and not to an edit view.

In fact, I actually want to remove the edit page as for these objects only new instances are allowed - no deletions or editing.

How do I achieve this?


probably the best way to do this is to override the Create action, but for your specific case though there is easier (but no so clean) solution.

Since you don't want to use edit action you can remove it from generator.yml list actions and then override '[YOUR_ITEM]_edit' route to point to items list page.

This way when new item is added you will be redirected back to items list page (overridden edit route) and also manual try to access edit action will redirect to items list page.

What you think?


I found the best way for this is to edit the form as such:

class CouponForm extends BaseCouponForm
{
  public function configure()
  {
        $this->getValidator('used')->setOption('required', false);
        $this->getValidator('valid_until')->setOption('required', true);
        $this->getValidator('created_at')->setOption('required', false);
        $this->getValidator('updated_at')->setOption('required', false);
  }
}

and then in the generator.yml file edit the 'edit' actions:

  edit:
    actions:           { _list: ~ }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜