Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

EditableFormFields with PageID == 0


Reply


2 Posts   1506 Views

Avatar
xmedeko

Community Member, 94 Posts

11 June 2007 at 2:01pm

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.

Avatar
Andy

230 Posts

15 June 2007 at 10:44am

Ok, this patch has been applied. You are right about it not completely solving the problem, I've creates a ticket so this should get fixed sometime.

Cheers
Andy