Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » EditableFormFields with PageID == 0

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

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

Page: 1
Go to End
Author Topic: 1469 Views
  • xmedeko
    Avatar
    Community Member
    94 Posts

    EditableFormFields with PageID == 0 Link to this post

    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.

  • Andy
    Avatar
    230 Posts

    Re: EditableFormFields with PageID == 0 Link to this post

    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

    1469 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.