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"….
Tag: Validation
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…
More cakephp 2.x infos and 3.x notes
Behaviors I just recently found out that the attach() and detach() methods I have always been using seem to be deprecated (or at least only available for BC) – and that one should probably use load() and unload() from now…
Tools Plugin – Part 2: Contact Form
I want to show how easy it is to make a solid and universal contact form in Cake(2). The full code can be found in the github rep of the Tools plugin. Model The most important part first: We need…
Maximum power for your validation rules
I already postet an article about custom validation rules some time ago here. In this post I introduce some of my custom rules which come in handy quite often. For being able to use it in different projects I do…
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…
How to implement Captchas properly
What is a captcha? They protect forms on websites from spammers and bots (@see Wikipedia for details). The main idea: Display some kind of code a human can easily read and submit but a computer can not. How NOT to…
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 &&…