Hi,
if you create a new UserDefinedForm (a contact form), add a few fields and save it, then there are EditableFormFields with PageID == 0. When you create a second new contact page, you see these fields in the new contact page. To fix this, I propose the following patch:
--- FieldEditor.orig2 2007-06-11 13:50:30.000000000 +1200
+++ FieldEditor.php 2007-06-11 13:54:01.000000000 +1200
@@ -70,13 +70,15 @@
$newEditableData = $_REQUEST[$name][$newEditableID];
// if( is_numeric( $newEditableID ) )
- $editable = DataObject::get_one( 'EditableFormField', "`ParentID`='{$record->ID}' AND `EditableFormField`.`ID`='$newEditableID'" );
+ //`ParentID`=0 is for the new page
+ $editable = DataObject::get_one( 'EditableFormField', "(`ParentID`='{$record->ID}' OR `ParentID`=0) AND `EditableFormField`.`ID`='$newEditableID'" );
// check if we are updating an existing field
if( $editable && $missingFields[$editable->ID] )
unset( $missingFields[$editable->ID] );
// create a new object
+ // this should be now obsolete
if( !$editable && !empty( $newEditableData['Type'] ) && class_exists( $newEditableData['Type'] ) ) {
$editable = new $newEditableData['Type']();
$editable->ID = 0;
@@ -87,6 +89,9 @@
}
if( $editable ) {
+ if($editable->ParentID == 0) {
+ $editable->ParentID = $record->ID;
+ }
$editable->populateFromPostData($newEditableData);
//$editable->write();
}
This patch does not solve the situation, when the user discards changes in the new contact form, though :-( The new fields should be created just by javascript in the browser. They should be created in the database when saving the draft.