from
imagepng($cropped,$filename,80);
imagepng($cropped,$filename,8);
The third parameter is for the quality of the image to be uploaded so for png it only supports from 0 - 9, above that it will cause warnings and errors.
imagepng($cropped,$filename,80);
imagepng($cropped,$filename,8);
A sample on how to use multiple select checkbox within cakephp views and controller.
After reviewing the http://api.cakephp.org/file/cake/libs/view/helpers/form.php#method-FormHelperselect
1.) Inserting to database
-View Decleration Example.
1 2 3 4 5 6 7 8 9 10 11 | <?php //add.ctp for example ?> <em>How would you describe your job (mark as many as applies): </em> <?php echo $form->input('describeJob', array('label' => false, 'div' => false, 'type' => 'select', 'multiple'=>'checkbox', 'legend' => 'false', 'options' => array('Physical' => 'Physical','Mental' => 'Mental', 'Stressful' => 'Stressful', 'Easy-going' => 'Easy-going', 'Secure' => 'Secure', 'Non-secure' => 'Non-secure', 'Exhausting' => 'Exhausting', 'Relaxing' => 'Relaxing' ) )); ?> |
-On your controller. Use implode php function and add a seperator that you like, for this example I use ","
1 2 3 4 5 6 | <?php //job_controller @add() function if (!empty($this->data)) { $this->data['Job']['describeJob'] = implode(",",$this->data['Job']['describeJob']); $this->Job->create(); ?> |
2.) Editing part, Retrieving values of the datafield to mark check on those were choosen before.
-View Decleration Example. In this example I used explode function of php directly in the view, notice the "selected" option added in to the $form->input helper, this will get the values, supposed to be check in that field.
1 2 3 4 5 6 7 8 9 10 | <? //edit.ctp for example $piecesJob = explode(",", $this->data['Job']['describeJob']); echo $form->input('describeJob', array('label' => false, 'div' => false, 'type' => 'select', 'multiple'=>'checkbox', 'legend' => 'false', 'options' => array('Physical' => 'Physical','Mental' => 'Mental', 'Stressful' => 'Stressful', 'Easy-going' => 'Easy-going', 'Secure' => 'Secure', 'Non-secure' => 'Non-secure', 'Exhausting' => 'Exhausting', 'Relaxing' => 'Relaxing' ), 'selected' => $piecesJob )); ?> |
That's it
Problem.
After I updated the database, I added 1 table; relate it to another table, and go to the command line to bake what I did, after typing "cake bake model" at the command prompt, I found out that the recently added table was not listed.
Reason.
Cake caches your model schema.
Solution.
1.)
Clear your cache by deleting all files in your app's tmp/cache/models/
and tmp/cache/persistent/
2.)
Disable caching in your app's config/core.php // make sure to enable back again in production setup
/** * Turn off all caching application-wide. * */ Configure::write('Cache.disable', true);
After doing the solution, I can now successfully bake the new table.