[PagePartBundle] Delete nested (non-entity) sub-items #3423
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a pagepart has sub-items which are not entities (just a simple 'model') and you want to delete one or more items, the following error occures:
This is normal as the regex which is used to find more information about the sub 'entity' (which is no entity in our case) does not match.
This is how the delete key is created.
For an entity this could be
delete_pagepartadmin_1653874_items_500
where500
is the ID of the sub entity.For a model (plain php class) as sub item, this could be
delete_pagepartadmin_1653874_items_testtitle
wheretesttitle
comes from{{ obj.vars.value }}
in the snippet below.src/Kunstmaan/AdminBundle/Resources/views/Form/fields.html.twig:180
In the
preBindRequest
function of PagePartAdmin the$matches
array of thepreg_match_all
should hold data like (in case of an entity sub item).In case of a model as subitem,
$matches
is an empty array, which is ok, as there should be no specific action on the list of subitems, Symfony form handling will delete this item from the array.BUT since the $matches array is empty the
preBindRequest
function should not add this to the$subPagePartsToDelete
array. This array is used to handle entity sub items.src/Kunstmaan/PagePartBundle/PagePartAdmin/PagePartAdmin.php:152