⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

[update] Problem inputbox with constrain double type (numeric with comma)



Muhammad Hanif Fahyuananto
  • profile picture
  • Member

Posted 03 August 2013 - 02:58 AM

I've found a new bug/problem with the constrain of input box.
First I think the contraint is set based on constrain that created in my database such as string, numeric, and length.
But when my field in database is double (3,2), the appropiated inputbox have different behavior, I just can type 3 digit without dot or 1digit-dot-1digit.
Why I can't type such as 6.32 but I just can type 6.3 or 632?
Is there any solution about this?
 

=============================================
 Update:
 I found that double type field from database is set become numeric rather than double. So, I've try to modify some lines in some part

 

protected function get_type($db_type) {       $type = false;
        if (!empty($db_type->type)) {            
            switch ($db_type->type) {                
                //some cases
                case 'timestamp':
                    $type = 'datetime';
                    break;
                case 'double': $type='double'; break;   //modified
            }
        }
        return $type;
    }

 

protected function get_field_input($field_info, $value = null) {
        $real_type = $field_info->crud_type;

        $types_array = array(
            'integer',
                 //some type
            'multiselect',
            'double'    //modified
        );

 

protected function get_double_input($field_info, $value) {
        $this->set_js_lib($this->default_javascript_path . '/jquery_plugins/jquery.numeric.min.js');
        $this->set_js_config($this->default_javascript_path . '/jquery_plugins/config/jquery.numeric.config.js');
        $extra_attributes = '';
        if (!empty($field_info->db_max_length)){
            $max_length=  explode(",",$field_info->db_max_length);            
            $extra_attributes .= "maxlength=".($max_length[0]+1).",".($max_length[1]);
        }
        $input = "<input id='field-{$field_info->name}' name='{$field_info->name}' type='text' value='$value' class='numeric' $extra_attributes />";
        return $input;
    }

 

I think the max-length in input such as 3,2 is just apply to 642 or 6.4 but when the max-length changed into 4.2, I can write 6.42 without any problem (include add, update process).

Is there any ideas about this, I'll appreciate it.


davidoster
  • profile picture
  • Member

Posted 05 August 2013 - 11:55 AM

Hello [member=Muhammad Hanif Fahyuananto].

I suggest you post an issue on github here about this.

Thanks for sharing this.