Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP - Custom validation function for the Uploader plugin
    primarykey
    data
    text
    <p>I want to use the custom validation functions in the Uploader behaviour, width and height, to create a new custom validation function which tests if the image is square. So when I am using the behaviour in the model this is how I am using the File Validation functions. I have outlined what I want to do below in the my SquareValidation function as well.</p> <pre><code> public $actsAs = array( 'Uploader.FileValidation' =&gt; array( 'image' =&gt; array( 'extension' =&gt; array( 'value' =&gt; array('gif', 'jpg', 'jpeg', 'png'), 'error' =&gt; 'You can only upload images' ), 'mySquareValidation' ) ) public function mySquareValidation () { return width = height; // WHAT IS THE RIGHT SYNTAX TO ACCESS WIDTH AND HEIGHT BEHAVIOUR FUNCTIONS? } </code></pre> <p>But how do I access those core (to the behaviour) validation functions inside a custom validation function and use them to check if the submitted file is square (I want to allow any height/width combo). I know that to call a core validation function (to CakePHP) I would for example simply use:</p> <pre><code>Validation::rule($this-&gt;data['field']) </code></pre> <p>So how do I do the same for the core validation functions belonging to the behaviour? And when I have created the custom validation function, do I then execute the function in the behaviour array just like I would in the validation array (like in my example)?</p> <p>Reference: Uploader docs - <a href="http://milesj.me/code/cakephp/uploader#validating-against-a-model" rel="nofollow">http://milesj.me/code/cakephp/uploader#validating-against-a-model</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload