I found it.
The problem wasn't where I put the code, the problem was caching of the viewdefs. So the first item seen after repair+rebuild would be the default for the others. I didn't spot the problem at first since I had SugarCRM set to Developer Mode, in which it does not cache viewdefs.
The easiest way to go is like this:
First, make a copy editviewdefs and name it whatever you like (mine is: closededitviewdefs.php)
Now, Change whatever you like in the newly created editview file.
After you made the changes, change the 5th line in closededitviewdefs.php from 'EditView' =>
to 'ClosedEditView' =>
When done, create a file in your module/views folder: view.edit.php. These are it's contents (replace module specific contents where applicable):
<?php
class [REPLACEWITHMODULENAME]ViewEdit extends ViewEdit {
public function preDisplay() {
$bean = $this->bean;
$isClosed = $bean->sent;
if ($isClosed==1) {
$metadataFile = 'custom/modules/[MODULEFOLDER]/metadata/closededitviewdefs.php';
$this->ev = $this->getEditView();
$this->ev->view = 'ClosedEditView';
} else {
$metadataFile = 'custom/modules/[MODULEFOLDER]/metadata/editviewdefs.php';
$this->ev = $this->getEditView();
}
$this->ev->ss =& $this->ss;
$this->ev->setup($this->module, $this->bean, $metadataFile, get_custom_file_if_exists('include/EditView/EditView.tpl'));
}
}
?>
This way two cache files are created from now on. There was one major problem with this: No header and footer in your closededitview! You can easily tackle this by adding the following to closededitviewdefs.php:
'form' =>
array(
'headerTpl' => 'include/EditView/header.tpl',
'footerTpl' => 'include/EditView/footer.tpl',
),
Make sure developer mode is off for correct testing results. Run Repair & rebuild. Now everything should work as expected. :)