Assuming I have a view in CakePHP which uses the Form Helper to create the form fields like so:
ec开发者_如何转开发ho $this->Form->create();
echo $this->Form->input('id');
echo $this->Form->input('headline');
echo $this->Form->input('paragraph');
echo $this->Form->end(__('Submit', true));
...and assuming once the form is submitted to the controller I then do a save() to update the record...
How would I include another input field in the form that is NOT associated to the model in question and which I want to put in there to capture another piece of data that I intend to process separately in the controller action?
(To give some background: the additional field I want to add is actually an image filename. My images table is a completely separate entity, and because it therefore has no association with the model I'm save()ing, I believe I need to capture the information in an additional field on the form, then process it 'manually' in the controller action - i.e., by importing the images model and creating a new record in it based on the image upload filename I've added to the form.)
Hope that makes sense!
Thanks.
echo $this->Form->input('file_image', array('type'=>'file'));
Then in your controller see what is returned and use that file and upload it to your server.
精彩评论