Articles tagged with behavior

TouchBehavior

By Jitka Koukalova
Would You like to have method touch() for some models, which updates only one field in database table and leaves 'created' and 'modified' (and all other) fields untouched?
[Read more]

Transaction behavior

By Christian Winther
A little behavior that enables you to use transactions in 1.2 without much work ;)
[Read more]

UTF8 Multibyte behavior

By Christian Winther
Simple way to make sure all your persisted data is in utf8 / same encoding
[Read more]

Sluggable Behavior

By Mariano Iglesias
This behavior lets your models act as slug-based models, useful for generating Search Engine friendly URLs. Easy to install, and easy to configure.
[Read more]

LDAP Models in CakePHP

By John David Anderson
Many organizations today utilize LDAP to store client and employee information. This tutorial will show you how to harness that data (as use in a CakePHP model) in your applications.
[Read more]

Simple Tagging Behavior

By DW
So far after looking at other tagging code in this site, I have not seen tags done properly when using normal database form. So this will be a basic, simple tagging system that allows you to use both a tags field in your table and a separate tagging table.
[Read more]

Soft Deletable Behavior

By Mariano Iglesias
This behavior lets you implement soft delete for your records in your models by introducing a flag to an existing table which indicates that a row has been deleted, instead of deleting the record.
[Read more]

counterCache or counter_cache Behavior

By Derick
I wrote this because I needed something simple for my recent project and CakePHP have not implemented the counterCache option yet. This is my first time writing a Behavior and largely based on http://groups.google.com/group/cake-php/msg/74508dad38d3d623 but it doesn't work for me though. You may wish to learn more about why counterCache is useful at http://groups.google.com/group/cake-php/msg/971ced72abe96b03
[Read more]

HABTM Add & Delete Behavior

By Brandon Parise
Many people gripe about the HABTM associations in CakePHP and how difficult it is to add or delete a single record. This behavior takes care of the task for you!
[Read more]

SimpleResults Behavior - Re-index results from findAll()

By JP Mortiboys
When returning rows from a Model::findAll() call, the result array is indexed in a certain way. This behavior allows models to return their results indexed in the same way as hasMany associations, which is more concise and (in certain circumstances) easier to parse / pass to other functions.
[Read more]

LDAP Models in CakePHP

By John David Anderson
Many organizations today utilize LDAP to store client and employee information. This tutorial will show you how to harness that data (as use in a CakePHP model) in your applications.
[Read more]

ConditionalValidation behavior

By franck
[Update]: as suggested few modifications :

- model method can be set in the condition
- syntax for fields in the condition can be 'Model.field' or "Model.field" (see example)
- usage of the beforeValidate callback
- "restore" parameter is now part of the settings

Suggestions and comments are welcome.

The validations in cake 1.2 are great, but sometimes I needed to have conditional validation. Because the validations are set at model level, i did implement a behavior that allows to turn on or off validation. I decided to share this on Bakery.
Do not hesitate to comment, I am not sure I have handle this in the correct way.
[Read more]

Bindable Behavior: control your model bindings

By Mariano Iglesias
With the birth of CakePHP 1.2 pre-beta, here comes the newly, improved, and extended version of Bindable, a method to easily control what model relationships are obtained from a find operation, and even customize binding settings.
[Read more]

Acts As Emailable

By Christopher E. Franklin
This little behavior is more of a learning experiment for me into how behaviors work in the CakePHP side of things. It helps me with maintaining a list of users who are emailable rather than write a component or a model. Read on for more...
[Read more]

Attachments

By David Persson
Even though there are already good solutions out there this project tries -as usual- to make things even a bit better and to provide a documented, easy to setup and use, extensible, clean implementation of the functionality described in detail below. Plus: It should work and integrate well into the framework everyone of us loves so much.

Parts of the code is based upon or inspired by `Improved Upload Behavior` by Tane Piper, `ImageHelper` by Jon Bennet, `Attach This!` by Alex McFadyen and `Generic Upload Behavior` by Andy Dawson.
[Read more]

ACL Behavior

By Steve Oliveira
This behavior is built off of the core Acl behavior. It fixes some issues with the core behavior and allows you to set a model as both an Aro and Aco. It also adds the alias where as the core behavior doesn't.
[Read more]

MySQL collation behavior

By Pawel Gasiorowski
A simple behavior that sets proper collation for order by SQL statements based on the current localization.
[Read more]

Increment Behavior

By Ketan
Increment Behavior is ideal for use when you want to increment a certain field by a delta increment such as adding votes, updating view counters, etc.
[Read more]