Just a quick note on how to style columns in grids and fields in editors
$grid->column('last_cost','Last Unit Cost Price (of last import)');
$grid->columns[2]->attributes = array('style' => 'text-align: right');
It seems simple, but it took me ages to figure out
This data edit sample uses some of the nicer features of Rapyd editing, namely:
1) Field Editing
2) Drop down lists (static and dynamic from db)
3) validation
4) Hidden fields
$edit = new dataedit_library(); $edit->label = $this->title; $edit->back_url = site_url('users_list'); $edit->source('user'); $edit->field('dropdown','customer_id','Customer') ->options('SELECT customer_id, company_name FROM customer') ->rule('required'); $edit->field('input','user_firstname','First Name') ->rule('min_length[3]|max_length[20]'); $edit->field('input','user_surname','Last Name') ->rule('min_length[3]|max_length[20]'); $edit->field('input','user_idnumber','ID Number') ->rule('exact_length[13]|unique[user]|numeric'); $edit->field('input','email','Email Address') ->rule('valid_email'); $edit->field('dropdown','province_id','Province') ->options('SELECT province_id, province_description FROM province where country_id = 1') ->rule('required'); $edit->field('dropdown','country_id','Country') ->options('SELECT id, name FROM country') ->rule('required'); $edit->field('dropdown', 'security_role_id', 'Security Role ID') ->options(array("1"=>"Administrator", "2"=>"User")); $edit->field('hidden','security_role_id','Security Role ID')->insert_value(2); $edit->field('hidden','activated','activated')->insert_value(1); $edit->buttons('modify','save','undo','back','delete'); $edit->build(); $data['head'] = $this->rapyd->head(); $data['title'] = $this->title; $data['content'] = $edit->output.'<br />'; |
Rapyd has some pretty useful validation rules. Pretty much all the ones that are in CodeIgniter + a few more
first create your edit grid
$edit = new dataedit_library(); $edit->label = $this->title; $edit->back_url = site_url('users_list'); $edit->source('user'); |
Here are some of the lesser well known ones:
unique[table_name] – if you use this validation rule, rapyd will make sure that the field you are using the rule on is unique in table_name
$edit->field('input','user_idnumber','ID Number') ->rule('exact_length[13]|unique[user]') ->rule('numeric'); |
valid_email – this will make sure the field is a valid email address
$edit->field('input','email','Email Address') ->rule('valid_email'); |
in_range[low,high] – this will make sure that the value you enter is between (low) and (high)
$edit->field('input','selling_incl','Selling (Incl VAT)') ->rule('required|in_range[' . $avg_cost . ',' . $real_value . ']'); |

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 