public function move($id, $direction)
    {
        $instance = $this->_getOrThrow($id);
        $unordered = [];
        $direction = !in_array($direction, ['up', 'down']) ? 'up' : $direction;
        $position = false;
        $list = $this->_getInstances();

        foreach ($list as $k => $field) {
            if ($field->id === $instance->id) {
                $position = $k;
            }

            $unordered[] = $field;
        }

        if ($position !== false) {
            $ordered = array_move($unordered, $position, $direction);
            $before = md5(serialize($unordered));
            $after = md5(serialize($ordered));

            if ($before != $after) {
                foreach ($ordered as $k => $field) {
                    $field->set('ordering', $k);
                    $this->FieldInstances->save($field);
                }
            }
        }

        $this->title(__d('field', 'Reorder Field'));
        $this->redirect($this->referer());
    }