sfDoctrineGenerator Delete does not work
-
11-06-2021 - |
Вопрос
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
Решение
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?