ModelAdmin - delete button hack

A ModelAdmin Delete button issue...

Problem
When editing a record in ModelAdmin, the Delete button to the bottom right of the screen won't work properly - at least not in v2.4.5.

Reason
The ModelAdmin::getResultColumns() function checks the $searchCriteria['ResultAssembly'] value to see if it should use the user-defined settings in the search form to the left, or default to the $summary_fields. Unfortunately it only checks the existance of theĀ  ResultAssembly item, not if it actually contains anything, in which case the $summary_fields should be returned, but aren't.

Fix:
A simple hack that should maybe be a bugfix if proven stable. For now it works for me, but if enyone sees weird things happening, please let me know.

/cms/code/ModelAdmin.php:

in ModelAdmin.php, somewhere around line 773, find the following:

if($selectedOnly && isset($searchCriteria['ResultAssembly'])) {

And replace by:

if ($selectedOnly && 
    isset($searchCriteria['ResultAssembly']) &&
    !empty($searchCriteria['ResultAssembly'])){

Backward and Forward?

Once the above is fixed, after a successful delete you now see a backward and forward button to the bottom left of the screen, that do not do anything useful and probably shouldn't be there anyhow. A quick-and-dirty hack to remove them: in ModelAdmin.php, somewhere around line 773, comment out these two lines:

new FieldSet(
   //new FormAction("goBack", _t('ModelAdmin.GOBACK', "Back")),
   //new FormAction("goForward", _t('ModelAdmin.GOFORWARD', "Forward"))
)

I know, not the cleanest of hacks, but removing the fieldset altogether will result in an error somewhere else, this works and, as v3.0 is around the corner, I'll leave it for now...

Comments

Het versturen van reacties is uitgeschakeld.

RSS feed voor reacties op deze pagina