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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Useless code in FieldEditor.php


Go to End


3 Posts   1799 Views

Avatar
xmedeko

Community Member, 94 Posts

11 June 2007 at 11:39am

Edited: 11/06/2007 11:39am

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

Community Member, 94 Posts

11 June 2007 at 1:24pm

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

$e->Sort = $nextSort;

later in the code

Avatar
Hayden

Core Development Team, 19 Posts

15 June 2007 at 10:31am

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.