Sunday, July 26, 2009

Re: Automatically Check a Checkbox

Thanks for the correction. However, I have tried this in several
places to no success. I just have some disconnect in how the
processing or logic flow works. Where do I need to place this nice
simple line of code?

I have put it in the Add function in several places, the only place
that did anything was when I made it the first line of code. Ha, at
least something happened. (I created a blank record with active set to
1.) Putting the line before the Create() or the Set() did nothing. I
even tried putting the line of code in the add.ctp. That seemed like
the wrong place to put it anyway but no check in the check box.

Should be clear that I am a beginner. I have tried searching the docs
and think my problem is terminology. Any links in the docs to set me
straight would be very welcome too. Thanks


On Jul 26, 6:02 am, euromark (München) <dereurom...@googlemail.com>
wrote:
> $this->data['MODELNAME']['active'] = 1;
>
> On 26 Jul., 06:34, Bart <bart.hardi...@gmail.com> wrote:
>
> > I have an tinyint(1) field in most of my tables named active default
> > value is set to null. By default I want the value of this field to be
> > 1. However, I cannot get the automagic checkbox to be checked in the
> > form. I cannot get the value to prime to 1. Seems simple enough but i
> > am still stuck.
>
> > I have tried setting the default value in the add.ctp.
>
> >         echo $form->input('active', array( 'default' => '1'));
> >         echo $form->input('active', array( 'default' => 1));
> >         echo $form->input('active', array( 'default' => true));
> >         echo $form->input('active', array( 'default' => 'true'));
>
> > None of these worked. Was not sure of the syntax so I tried everything
> > but the sink.
>
> > I tried adding a line to the file_controller.php in the add function.
>
> >        $this->data['file']['active'] = 1;
>
> > I could not get it to work this way either. Not sure exactly where in
> > the add function the form is actually called or if I am in the right
> > direction. So I tried it in several places.
>
> > I have also tried changing the default value in the mysql table. Still
> > not getting it.
>
> > I really think this should be simple but I am floundering. I know I am
> > making it too hard. Please point me in the right direction.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: