THIS PROJECT IS NO LONGER MAINTAINED AS I HAVE SWITCHED TO RUBY ON RAILS.
OH, AND PLEASE STOP SENDING ME PHP JOB OFFERS, I'M NOT INTERESTED IN COMING BACK.
As I couldn't find any usable CRUD, I've decided to create my own. It's based on Formo and Kohana's ORM.
I've included both HTML+PHP and Haml templates as I'm using Kohana3-Haml. If you wish to create more templates for different template systems, be my guest and create a pull request :)
Everything is pretty much straightforward and uses existing codebase. Rules for form are created using default ORM's rules() method (see http://kohanaframework.org/3.2/guide/orm/validation on how to use it), and additional parameters (like to ignore ID in form) is in formo() method (see Formo's documentation for both parameters and how to use them in your model)
Your most basic controller would probably look something like this:
<?php
class Controller_Crud_Products extends Controller_Crud
{
protected $_index_fields = array(
'id',
'name'
);
protected $_orm_model = 'product';
}
And basic model would be:
<?php
class Model_Product extends ORM
{
public $_belongs_to = array('category' => array());
public function formo()
{
return array
(
'id' => array
(
'render' => false
),
);
}
public function rules()
{
return array
(
'name' => array
(
array('not_empty')
),
);
}
}
I've also included a sample route in init.php, feel free to copy it to your bootstrap.php and modify it to suit your needs.
No need. No, seriously, everything you'd want is already covered somewhere else. Good places to start:
- Formo documentation, most important: getting started, ORM, parameters,
- ORM documentation, most important: validation
- lots of API docs because Kohana developers love API docs, am I right? ...
Everything configurable is covered in Kohana_Controller_Crud comments.