Jump to content


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

validation inputbox

  • Please log in to reply
1 reply to this topic

#1 Muhammad Hanif Fahyuananto

Muhammad Hanif Fahyuananto

    Newbie

  • Members
  • Pip
  • 6 posts

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.



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 05 August 2013 - 11:55 AM

Hello Muhammad Hanif Fahyuananto.

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

Thanks for sharing this.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr






Also tagged with one or more of these keywords: validation, inputbox

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users