Behaviors
Bindable Behavior: control your model bindings
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] MySQL collation behavior
A simple behavior that sets proper collation for order by SQL statements based on the current localization.
[Read more] Text Formatting
So I created a component awhile back for Textile. Turns out, it would be a little friendlier to just dump it in a behavior and let the model define fields that need to be saved with a textile'd version. It assumes that the textile'd fieldname has html_ added to it.
This also has options for
[Read more] This also has options for
Polymorphic Behavior
A behavior which will allow a model to be associated with any other model.
[Read more] ACL Behavior
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] Attachments
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] 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.
Acts As Emailable
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] ConditionalValidation behavior
[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] - 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.
ActAs Image column behavior
This behavior add new column to your model and allow to store images in file system. It can resize images, create several versions, and thubnails. After find model you got link to file for each record in model.
[Read more] Uuid Behavior
I have a requirement to use UUID's as primary keys. I was initially using MySQL triggers to call uuid() on insert but in the end decided a behavior makes more sense. This behavior adds a UUID to the field specified in your models.
[Read more] SimpleResults Behavior - Re-index results from findAll()
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] HABTM Add & Delete Behavior
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] counterCache or counter_cache Behavior
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] Simple Tagging Behavior
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
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] Toggle behavior
A small snippet to toggle an ENUM field in a SQL :)
[Read more] Null Behavior
Problems with default NULL fields not being very NULL'ish ?
[Read more] UTF8 Multibyte behavior
Simple way to make sure all your persisted data is in utf8 / same encoding
[Read more] Sluggable Behavior
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] TouchBehavior
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
A little behavior that enables you to use transactions in 1.2 without much work ;)
[Read more]
Latest Comments