[eluser]@li[/eluser]
[quote author="slowgary" date="1247216617"]I'm curious to know what the form looks like. Other than that, does it use CI validation? Is this production ready and would you actually use it for clients? And finally, will this really suffice for ALL occasions?
Thanks for playing.[/quote]
Well, the forms can look like however you design them. I'm attaching screenshots of a page I built with the following code, which is a bit long, but the form had a LOT of fields:
Code:
<?php
require_once(APPPATH.'/crud/Crud.php');
class Owners extends CrudController
{
function Owners()
{
parent::Controller();
$this->entityName='Site Owner';
$this->model='owner';
$this->url='admin/owners';
$this->setDefaults();
$this->addGridField('land_owner');
$this->addGridField('contract');
//3rd argument tells it to format the values of this column as dates.
//This changes them from YYYY-MM-DD to 13th August, 3009, etc
$this->addGridField('contract_date','','date');
$this->addGridField('last_payment','Last rent payment');
$this->addGridField('last_payment_period');
//3rd argument tells it to format the values as money.
//Results can be seen in crud1.jpg
$this->addGridField('gst','GST','money');
$this->addGridField('total_paid','','money');
$this->addGridField('to_pay','','money');
$this->addGridField('paid_amt','Paid Amount','money');
$this->addGridField('side_or_site');
$this->addGridField('payment_status');
$this->addTextarea('real_property_desc', '', '', '', '', 7, 50);
$this->addTextbox('land_owner');
$this->addTextbox('contract');
$this->addDate('contract_date', '', '','Contract due date');
$this->addTextbox('work_phone');
$this->addTextbox('home_phone');
$this->addTextbox('mobile');
$this->addTextbox('fax');
$this->addTextbox('email', '', '', 'valid_email');
$this->addSelect('last_payment', $this->_lastPaymentOpts(), '', '', '', 'is_numeric', 'Last rent payment');
$this->addTextbox('last_payment_period', '', '', '', 'Last rent payment period');
$this->addTextbox('gst', '', '', 'numeric', 'GST', 4,'','<b>$</b> ');
$this->addTextbox('total_paid', '', '', 'numeric', '', 4,'','<b>$</b> ');
$this->addTextbox('to_pay', '', '', 'numeric', '', 4,'','<b>$</b> ');
$this->addTextbox('paid_amt', '', '', 'numeric', 'Paid amount', 4,'','<b>$</b> ');
$this->addTextbox('side_or_site');
$this->addSelect('payment_status', array('Paid'=>'Paid','Unpaid'=>'To be paid'));
$this->addDate('paid_upto');
$this->addTextbox('invoice');
$this->addTextbox('cheque');
$this->addTextbox('bsb');
$this->addTextbox('acct_num', '', '', '', 'Account number');
$this->addTextbox('bank');
$this->addTextarea('comments', '', '', '', '', 7, 50);
}
function _lastPaymentOpts()
{
$opts=array();
for ($x=0; $x<=20; $x++)
{
$opts[$x]=$x;
}
return $opts;
}
}
?>
Notice how I only pass it the name of the field, e.g payment_date, and it automatically capitalizes it, removes underscores, etc on the actual forms and on the grid, showing 'Payment date' there.
Its definitely production ready though I need to add a class for producing radios (the project i was working on when I made this needed only textboxes, textareas, selects, and checkboxes).
Yes, it does use CI validation.