CakePHP change a view to have an image upload field in it

Written by James McDonald

October 18, 2011

# add array('type'=>'file') to the Form->create method
< ?php echo $this->Form->create('Map', array('type'=>'file'));?>
	
< ?php __('Add Map'); ?> < ?php # most fields are just normal automagic text/numeric/boolean fields echo $this->Form->input('name'); echo $this->Form->input('locality'); echo $this->Form->input('suburb_id'); echo $this->Form->input('map_type_id'); # change the field you want to become the upload field to have a file type # if you want a label you also need # if you are changing a field you need to change the model too # because it passes an array to cakephp echo $this->Form->input('upload', array( 'type' => 'file', 'label' => "XCF File")); echo $this->Form->input('source_image'); echo $this->Form->input('thumb_image'); echo $this->Form->input('tiled_image'); echo $this->Form->input('division_id'); echo $this->Form->input('dir'); echo $this->Form->input('mimetype'); echo $this->Form->input('filesize'); echo $this->Form->input('active'); ?>
< ?php echo $this->Form->end(__('Submit', true));?>

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

How to Research a CPU Upgrade

How to Research a CPU Upgrade

Upgrade Time! Doing a lot of VMWare Workstation virtualization to create labs for self-study and training. Finding...