I finally tracked down the problem. The reorder method calls children
to get the nodes of the root level first, but children has the
following condition:
if ($id === null && $model->id) {
$id = $model->id;
} elseif (!$id) {
$id = null;
}
So if you were saving things to the model beforehand, the $model->id
is probably still set. Do unset() or $model->id = null; before calling
reorder and everything works.
Is there some sort of cleanup or reset method for the model?
-Corie
On Oct 9, 3:07 pm, Corie <[EMAIL PROTECTED]> wrote:
> I'm having a strange issue with theTreebehavior method, reorder().
>
> If I do this it works:
>
> function order() {
> $this->Page->reorder(array('field' => 'Page.order', 'order' =>
> 'ASC'));
>
> }
>
> But if I do this, it won't reorder thetree:
>
> function order() {
> $this->data = array();
> foreach($this->params['form']['rows_list'] as $order => $id) {
> $this->data[] = array('id' => $id, 'order' => $order);
> }
> $this->Page->saveAll($this->data);
>
> $this->Page->reorder(array('field' => 'Page.order', 'order' =>
> 'ASC'));
>
> }
>
> I know the saving of my order fields is working because I can do the
> saveAll, edit the function putting the reorder() call first, then call
> the function again and it will reorder it properly. The order()
> function here is being called by Ajax. Anyone have a clue?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---