it should be "disabled" => "disabled" or "disabled" => "checkbox" instead
"disabled" => true
--
Lep pozdrav, Tilen Majerle
http://majerle.eu



2011/10/25 MetZ <[email protected]>

> Hi all..
>
> I just wanted to let anyone else with similar problem know how I
> solved this.
>
> in view!
>  <?php
>        if($this->data['Content']['category_id'] != '')
>        {
>        $cont_cats = explode(",",$this->data['Content']['category_id']);
>        }else{
>        $cont_cats = '';
>        }
>        echo $form-
> >input('category_id',array('size'=>'10','div'=>false,'label'=>false,'type'
> => 'select', 'multiple' => true,'options' =>
> array($categories),'selected' =>$cont_cats));
>         ?>
>
> Now it is working as it should =)
>
> Have fun, and thanks for all help!
> -Tom
>
>
>
> On 13 Okt, 12:46, WebbedIT <[email protected]> wrote:
> > If this is a HABTM relationship, which it would have to be to allow
> > many contents to be related to many categories, then you have your
> > field named wrong.
> >
> > You essentially have a belongsTo field there where one row can only
> > have one relation to Category via Content.category_id, what you need
> > is a field like:
> > $this->Form->input('categories', array('type'=>'select',
> > 'multiple'=>'checkbox', 'options'=>$categories));
> >
> > This will give you a data[Category][Category] type array.
> >
> > Book entry:
> http://book.cakephp.org/view/1034/Saving-Related-Model-Data-HABTM
> >
> > HTH, Paul.
> >
> > On Oct 12, 6:16 pm, MetZ <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > It is not to display all categories (options), it is on EDIT, to set
> > > SELECTED on a category option that are selected.
> >
> > > Example: admin_edit.ctp view
> > > echo
> $form->input('Content.category_id',array('selected'=>$this->data['Content']
> >
> > > ['category_id'],'size'=>'10','div'=>false,'label'=>false,'type'
> > > =>'select', 'multiple' => true,'options' => array($categories)));
> >
> > > The array of the SELECTED categories does not work, have tried many
> > > different versions of find in the controller to list the selected
> > > categories.
> > > $this->data['Content']['category_id'] = 1,3,7
> >
> > > Output:
> > >  <input name="data[Content][category_id]" value=""
> > > id="ContentCategoryId_" type="hidden">
> > > <select name="data[Content][category_id][]" size="10"
> > > multiple="multiple" id="ContentCategoryId">
> > > <option value="1" SELECTED>Test Cat1</option>
> >
> > > <option value="3">.. Test Cat 2</option>
> > > <option value="7">Test3</option>
> > > </select>
> >
> > > I can NOT get the SELECTED inserted to other options than the first
> > > one in the array. I have no idea why this is happening
> > > If I echo $this->data['Content']['category_id']
> > > it output: 1,3,7 so the array contains the ids that where selected
> > > when the content was created.
> >
> > > Any and all help on this will be appreciated!!
> > > Thanks all.
> >
> > > -Tom
> >
> > > On 11 Okt, 13:36, euromark <[email protected]> wrote:
> >
> > > > why not
> > > > 'options' => $categories
> > > > ?
> >
> > > > since $categories probably is an array and contains the keys
> >
> > > > On 10 Okt., 21:38, MetZ <[email protected]> wrote:
> >
> > > > > Hi all.
> >
> > > > > I am having trouble setting the selected to the options when
> selected
> > > > > is an array.
> >
> > > > > (This is a edit content view)
> > > > > Dropdown display all categories (using generatetreelist to list my
> > > > > categories)
> >
> > > > > echo
> $form->input('Content.category_id',array('selected'=>array($this->data['Con
> tent']
> >
> > > > > ['category_id']),'size'=>'10','div'=>false,'label'=>false,'type' =>
> > > > > 'select', 'multiple' => true,'options' => array($categories)));
> >
> > > > > My array:  $this->data['Content']['category_id'] = '4,5,6,7'
> >
> > > > > Only the number 4 category option get "selected" in the dropdown.
> >
> > > > > Anyone know if this is a bug or am I missing something here? I can
> not
> > > > > see it, please help ;)
> >
> > > > > Thanks all!!
> > > > > -Tom
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to