Link to home
Start Free TrialLog in
Avatar of error77
error77

asked on

CakePhp Submit extra Values

Hi all,
I have a form in a view and I also have some variables which I need to submit.

My view looks like this:

<?php
echo $form->create('Upload',array('type'=>'file', 'url' => 'uploads'));
echo $form->input('0.file',array('type'=>'file','label'=>'Image Upload: '));
echo $form->end('Submit');
?>

The above works fine and submits to table but the table has other fields too so I'd like to submit them too.

For example - something like this:

echo $form->input('Upload', array('user_id' => '100'));

The table has also a field called user_id and I'd like to add this.

How can I do this please?

I know the format is not:

echo $form->input('Upload', array('user_id' => '37'));

What would it be ... if possible please?

thanks



Avatar of cwiedmann
cwiedmann

I think you're looking for $form->hidden().  See http://book.cakephp.org/view/723/hidden

I think $form->hidden('user_id') should do the right thing as long as your model is set up correctly.
Avatar of error77

ASKER

I agree with you but there's a small issue here.
I have the user_id in a variable and need to add it to the form as a value.

If I used $form->hidden('user_id') .. the added user_id on the left would be null as it's not been assigned yet.

Know what I mean?
ASKER CERTIFIED SOLUTION
Avatar of cwiedmann
cwiedmann

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of error77

ASKER

Perfect! Thanks very much :o)