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

Useless code in FieldEditor.php


Reply

3 Posts   1364 Views

Avatar
xmedeko

11 June 2007 at 11:39am (Last edited: 11 June 2007 11:39am), Community Member, 94 Posts

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")) {

Avatar
xmedeko

11 June 2007 at 1:24pm Community Member, 94 Posts

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

$e->Sort = $nextSort;

later in the code

Avatar
Hayden

15 June 2007 at 10:31am Core Development Team, 19 Posts

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.