Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Useless code in FieldEditor.php

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: 1350 Views
  • xmedeko
    Avatar
    Community Member
    94 Posts

    Useless code in FieldEditor.php Link to this post

    Hi,
    this piece of code seems useless:

    --- FieldEditor.php.orig 2007-01-19 12:01:24.000000000 +1300
    +++ FieldEditor.php 2007-06-11 11:35:20.000000000 +1200
    @@ -114,16 +114,6 @@
    }*/

    function addfield() {
    - // get the last field in this form editor
    - $parentID = $this->form->getRecord()->ID;
    - $lastField = DataObject::get('EditableFormField', "`ParentID`='$parentID'", "`Sort` DESC", null, 1 );
    -
    - $nextSort = 1;
    -
    - // the new sort value is the value of the last sort + 1 if a field exists
    - if( $lastField )
    - $nextSort += $lastField->Sort;
    -
    $className = "Editable" . ucfirst($_REQUEST['Type']);
    $name = $this->name;
    if(is_subclass_of($className, "EditableFormField")) {

  • xmedeko
    Avatar
    Community Member
    94 Posts

    Re: Useless code in FieldEditor.php Link to this post

    maybe it's not useless, maybe there should be something like

    $e->Sort = $nextSort;

    later in the code

  • Hayden
    Avatar
    Core Development Team
    19 Posts

    Re: Useless code in FieldEditor.php Link to this post

    I think you are right there. It looks like the line to update the sort of the new element is missing.

    The default ordering would display the fields in the expected order.

    1350 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.