Skip to content

Commit

Permalink
scoumbourdis#141 - Maxlength for decimal numbers
Browse files Browse the repository at this point in the history
Fixed issue scoumbourdis#141, so that decimal numbers have enough max-length in
input field, accounting for the decimal character.
  • Loading branch information
bzuro committed Sep 18, 2013
1 parent 71dc492 commit fc91b31
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion application/libraries/Grocery_CRUD.php
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,12 @@ protected function get_string_input($field_info,$value)

$extra_attributes = '';
if(!empty($field_info->db_max_length))
$extra_attributes .= "maxlength='{$field_info->db_max_length}'";
if($field_info->type=='decimal'){
$decimal_lentgh = explode(',',$field_info->db_max_length);
$extra_attributes .= "maxlength='".($decimal_lentgh[0]+1)."'";
}else{
$extra_attributes .= "maxlength='{$field_info->db_max_length}'";
}
$input = "<input id='field-{$field_info->name}' name='{$field_info->name}' type='text' value=\"$value\" $extra_attributes />";
return $input;
}
Expand Down

0 comments on commit fc91b31

Please sign in to comment.