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.

Customising the CMS

How to make children movable?


7 Posts   159 Views


11 August 2014 at 6:23am Community Member, 9 Posts

Hi All,

I've a DataObject ClassRoom which has a many Students. Each student can only be assigned to one ClassRoom.

I've a ModelAdmin for the ClassRoom objects.

Now I'd like to move one Stundent form one ClassRoom to another.

I'd like to do that with making the parent ClassRoomID in the Stunden data object editable.

I tried to make the parent id editable - but that doesn't work.

Thanks for your help.


11 August 2014 at 2:40pm Community Member, 42 Posts

If I was going to to do something like this I would have a has_one for the ClassRoom on the Student model and override getCMSFields to add a new dropdown field for the classroom

public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->push(new DropdownField('ClassRoom', 'Select Class room', ClassRoom::get());
return $fields;


12 August 2014 at 6:28am Community Member, 9 Posts

I tried that, but doesn't work.

What happens is, if I change the id and press save - nothing happens. The id is automatically resetted to the old one.

Somehow it seems that I cannot change a parent id?


12 August 2014 at 9:23am Community Member, 42 Posts

What are you using for the name for the classroom it should be ClassRoomID (or whatever the name is in the the DB) in the example I posted I put ClassRoom when it should have probably been ClassRoomID


13 August 2014 at 7:01am Community Member, 9 Posts

Doesn't seem to work. ( with ClassRoomID and ClassRoom )

Here is the code I'm using:

Do you have another idea?

Thanks for your help!


13 August 2014 at 9:06am Community Member, 42 Posts

Tried your code on a fresh install and it works from the ClassRoom model admin.
When I go into the ClassRoom Model admin next to the main tab I have a student tab where I can link existing students to a classroom.
I am using a 3.1 install


7 September 2014 at 12:45am (Last edited: 7 September 2014 12:46am), Community Member, 9 Posts

It does work with the link-existing tool.

But my use case is, that I want to go within the class room, select one student and on the student level I should be able to move him to another classroom.

Like this: