[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

CakePhp Submit extra Values

Posted on 2010-09-01
4
Medium Priority
?
422 Views
Last Modified: 2013-11-10
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



0
Comment
Question by:error77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:cwiedmann
ID: 33581692
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.
0
 

Author Comment

by:error77
ID: 33581752
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?
0
 
LVL 5

Accepted Solution

by:
cwiedmann earned 2000 total points
ID: 33581802
In that case you could do $form->hidden('user_id', array('value'=>'37'));

Of course you can substitute a view variable for the '37' as needed.
0
 

Author Closing Comment

by:error77
ID: 33581859
Perfect! Thanks very much :o)
 
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question