# |
Aug 7th 2008, 13:57 |
ethanm |
I am providing $form->input with an array of $options that are numerically indexed, but the form helper doesn't preserve the keys when it makes a select box |
# |
Aug 7th 2008, 13:56 |
mandys |
or should they be under controllers? |
# |
Aug 7th 2008, 13:45 |
darkangel |
Hi. If you are using a multi-select box for a HABTM, and therefore the field name is Category.Category, for example, where do you perform the validation? As a 'Category' validation rule in the Category model? |
# |
Aug 7th 2008, 13:44 |
jaredhoyt |
beatzombies: the easiest way to perform that in the controller is add if(empty($this->data)) { $this->data = load some data here ... } else { process submitted data } |
# |
Aug 7th 2008, 13:37 |
beatzombies |
jaredhoyt: wait, so when i reference ContributorsItem as in $form->checkbox('ContributorsItem.contributed'); what does cakephp look at to get that value? |
# |
Aug 7th 2008, 13:36 |
beatzombies |
jaredhoyt: thanks, ill definitely be back with more questions |
# |
Aug 7th 2008, 13:36 |
beatzombies |
jaredhoyt: alright, i see i need to think about this some more |
# |
Aug 7th 2008, 13:35 |
jaredhoyt |
you're view variables are lost ;) |
# |
Aug 7th 2008, 13:35 |
jaredhoyt |
beatzombies: when you hit submit, only form data is passed into the controller action |
# |
Aug 7th 2008, 13:35 |
beatzombies |
i see |
# |
Aug 7th 2008, 13:35 |
beatzombies |
jaredhoyt: so when i submit i wouldnt be able to just do a save() because the submitted data to the controller would not be model information |
# |
Aug 7th 2008, 13:35 |
jaredhoyt |
if you're setting db data into a view var, then you'd do something like <?php echo $form->checkbox('Model.fieldname', array('value' => $view_var['path_to_field']); ?> |
# |
Aug 7th 2008, 13:33 |
jaredhoyt |
beatzombies: well, save them as you would any other form data |
# |
Aug 7th 2008, 13:33 |
beatzombies |
jaredhoyt: and then manually set the values in the database when im updated those values? |
# |
Aug 7th 2008, 13:32 |
jaredhoyt |
beatzombies: then you're going to have to manually set the checkbox value |
# |
Aug 7th 2008, 13:32 |
beatzombies |
jaredhoyt: is that the wrong way to do things? |
# |
Aug 7th 2008, 13:32 |
jaredhoyt |
if you just want to display data in text form, then do $this->set('some_var', $this->Model->find()) |
# |
Aug 7th 2008, 13:32 |
beatzombies |
jaredhoyt: i am kind of making my own array of values from various models in my controller and setting that for my view to use |
# |
Aug 7th 2008, 13:32 |
beatzombies |
jaredhoyt: oh, i see |
# |
Aug 7th 2008, 13:31 |
jaredhoyt |
if you want form inputs to automatically load db data |
# |
Aug 7th 2008, 13:31 |
jaredhoyt |
or read() or whatever |
# |
Aug 7th 2008, 13:31 |
jaredhoyt |
$this->data = $this->Model->find() |
# |
Aug 7th 2008, 13:31 |
jaredhoyt |
it is if you set it in the controller |
# |
Aug 7th 2008, 13:30 |
beatzombies |
jaredhoyt: hmm, is there a $this->data varialbe defined in the view? |
# |
Aug 7th 2008, 13:28 |
beatzombies |
jaredhoyt: let me try that |
# |
Aug 7th 2008, 13:28 |
jaredhoyt |
beatzombies: have you do a pr() of $this->data in your view to make sure the correct field is getting loaded w/ the correct value? |
# |
Aug 7th 2008, 13:27 |
beatzombies |
jaredhoyt: i have a feeling i am going about things the wrong way |
# |
Aug 7th 2008, 13:27 |
beatzombies |
jaredhoyt: nope |
# |
Aug 7th 2008, 13:27 |
zmonteca |
question about routing....when you Router::connect() something, does that actually map or redirect? It seems when i'm using that it's actually redirecting...simpley because my Session['Auth']['redirect'] is getting set with a url from Router::Connect() |
# |
Aug 7th 2008, 13:27 |
jaredhoyt |
beatzombies: did you get your checkboxes working? |
# |
Aug 7th 2008, 13:23 |
jaredhoyt |
D |
# |
Aug 7th 2008, 13:23 |
atula |
I use $this-> |
# |
Aug 7th 2008, 13:22 |
jaredhoyt |
how would you call any method in the controller? :) |
# |
Aug 7th 2008, 13:21 |
atula |
jaredhoyt: to call it in a controller's action, do I have to do $this->__myPrivateFunction or can I just call it __myPrivateFunction ? |
# |
Aug 7th 2008, 13:20 |
atula |
thank you jaredhoyt |
# |
Aug 7th 2008, 13:20 |
jaredhoyt |
atula: _ for protected, __ for private |
# |
Aug 7th 2008, 13:19 |
francky06l |
Hi Bakers :-) |
# |
Aug 7th 2008, 13:19 |
atula |
to declare a function that's not an action do I do function __functionname() in the controller ? |
# |
Aug 7th 2008, 13:18 |
beatzombies |
teknoid: here is the controller code I am using http://bin.cakephp.org/view/1338264000 |
# |
Aug 7th 2008, 13:18 |
jaredhoyt |
k ;) |
# |
Aug 7th 2008, 13:18 |
tomas- |
jaredhoyt, thanks, its everything |