Test composer dependencies with prefer-lowest


This 4 year old post already blogged about it. Surprisingly many libraries still don’t use it in their CI system yet. The –prefer-lowest option has been added around that time. Composer documentation says: "Useful for testing minimal versions of requirements"….

CakePHP Tips – Winter 2012


Some more tips I gathered the last couple of weeks and want to share with the (Cake/PHP)world 🙂 Jquery and CakePHP FormHelper::radio() Usually you would use var value = $(‘input[name=fieldName]:checked’).val(); But since CakePHP uses name="data[ModelName][field_name]" generating the form fields you…

Saving Model Data and Security


In google groups there are quite a few discussions every month about security against (primary key) injection, xss or other things. And yes, the default templates will not protect you from any of this. They are meant to produce quick…

Extended core validation rules


I18n Translation Some translate the rules in the view – but it usually creates redundancy. In some projects this might be intentional. I like to keep the error messages centralized, though. For that, you can just override the core translation…

Working with forms


The Cookbook only covers the real basics. I want to go over some common issues in a more detailed way for Cake1.3 apps. Dummy Values Dummy values for select fields are usually added in the view: /* (1) */ echo…

Validating multiple models at once


There are forms where you want to add/edit not only fields of the current model, but also of a related one (usually hasMany or belongsTo). Example: User and Post $this->Post->set($this->data); $this->Post->User->set($this->data); $val1 = $this->Post->validates(); $val2 = $this->Post->User->validates(); if ($val1 &&…