duannuochi3549 2012-05-30 07:57
浏览 42
已采纳

sfDoctrineGenerator删除不起作用

Lately, I have been exploring the sfDoctrineGenerator of Symfony for my backend interface. The problem is this:

I am using sfDoctrineGuardPlugin for user management. The sfGuardUser module uses sfDoctrineGenerator. All of the functions needed (delete, edit, add) are working. So far so good.

I then created a new module using this link as reference. The add and edit functions now work but I can not make delete (both batch and single delete) work. I tried to explicitly add it under the batch actions, but it still does not work. It says that it has already deleted showing a flash message success, but no element was deleted. Can someone point me to the right direction where the problem could have originated?

Here is a copy of my generator.yml

generator:
  class: sfDoctrineGenerator
  param:
    model_class:           News
    theme:                 admin
    non_verbose_templates: true
    with_show:             false
    singular:              ~
    plural:                ~
    route_prefix:          news
    with_doctrine_route:   true
    actions_base_class:    sfActions

    config:
      actions: ~

      fields:  
        news: {label: Announcement}
        created_at: {label: Date Published}
        updated_at: {label: Date Updated}
        user_id: {label: Author}
        user_name: {label: Author}

      list:    
        title:          Announcements List
        display:        [=title, created_at, updated_at, user_name]
        sort:           [created_at, desc]
        max_per_page:   10
        batch_actions:
          _delete:    ~

      filter: 
        display:  [title, user_id]

      form:   
        class:    NewsForm

      edit:    
        title:    Editing Announcement "%%title%%"

      new:     
        title:    New Announcement

If you need something else from me, please do not hesitate to comment. Any help will be much appreciated. Thanks in advance.

UPDATE:

Here is the request header as viewed in Chrome:

Request URL:http://localhost:8080/inventory_dev.php/news
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:ja_purity_tpl=ja_purity; fontSize=100; __atuvc=312|19; JSESSIONID=9DDD204812F0C53A8B3D33B89BF7A7C8; matciis=ha6l8ci8h3i2bp696e4h33vig2; symfony=ld2qept3j5cddjsb16qie098u3
Host:localhost:8080
Referer:http://localhost:8080/inventory_dev.php/news
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5
Response Headersview source
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:text/html; charset=utf-8
Date:Wed, 30 May 2012 08:30:02 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=99
Pragma:no-cache
Server:Apache/2.2.21 (Win32) PHP/5.3.8
Transfer-Encoding:chunked
X-Powered-By:PHP/5.3.8
  • 写回答

1条回答 默认 最新

  • douqiao6563 2012-05-30 08:50
    关注

    This is one of the D'OH moments in life.

    The problem was that in my schema.yml, I specified:

    actAs: { Timestampable: ~ , SoftDelete: ~ }
    

    This means that when I delete the element, it only adds the timestamp to it instead of physically deleting it. I removed the SoftDelete from the configuration and the problem was fixed.

    Maybe there should be a functionality in sfDoctrineGenerator to support SoftDelete?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度