Thanks for the reply, for some reason when I tried the 'empty' option
it didn't work, hence my question here.
And thanks for the beforeSave() hint.
On May 7, 8:44 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
> I can't help you with the scaffolding - never used it, but it's
> certainly possible to do what you want.
>
> 1) Do this in your view.
>
> echo $form->input('Product.parent_id', array('options' => $categories,
> 'empty' => '-- Top Level --'));
>
> You might need this in your model...
>
> function beforeSave(){
> if (isset($this->data[$this->alias]['parent_id']) &&
> empty($this->data[$this->alias]['parent_id'])){
>
> $this->data[$this->alias]['parent_id'] = null;
> }
> return true;
> }
>
> 2) The Tree behaviour has generatetreelist() however it display likes
> this:
>
> Parent 1
> _Child 1-1
> _Child 1-2
> Parent 2
> _Child 2-1
> _Child 2-2
> __Subchild 2-2-1
>
> I think you would need to create your own method to generate the data
> in the format you wish.
>
> Cheers,
> Adam
>
> On May 8, 4:32 am, benjam <[EMAIL PROTECTED]> wrote:
>
> > I have a location table with the following fields:
> > -------
> > id
> > name
> > location_id -- this is a parent location id
> > -------
>
> > I have a couple of questions about getting this to work the way I want
> > it to using scaffolding.
>
> > 1- How can I set it up so the location_id select box on the form has a
> > default value of 0 - 'Top Level' without putting a 'Top Level' entry
> > in the table?
>
> > 2- How can I get the select box to output in the following format?
>
> > -- Top Level --
> > Parent 1
> > Parent 1 :: Child 1-1
> > Parent 1 :: Child 1-2
> > Parent 2
> > Parent 2 :: Child 2-1
> > Parent 2 :: Child 2-2
> > Parent 2 :: Child 2-2 :: Subchild 2-2-1
> > etc.
>
> > where the tree is built in the order of the ids of the parents, then
> > the order of the idds of the children.
>
> > I can do this manually, but I'd like to know a 'Cake' way of doing it.
>
> > And if I must do this manually, how do I get it to play nice with the
> > $form->input method? If I need to at all?
>
> > Thanks for your help.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---