Jump to content


Decimal values with problem on before_update callback

callback decimal

  • Please log in to reply
3 replies to this topic

#1 Romac

Romac

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 18 August 2013 - 02:26 AM

Guys, please i need your help!

 

   This is my problem:

 

 In my country (Brazil), the decimal separator is the comma ",", so:

 

$crud->callback_column('preco',array($this,'valueToReal'));

 

 

function valueToReal($value, $row)
{
    return 'R$ '.number_format($value, 2, ',', '.');    //$value.' €';
}

 

 

This show the values on correct format, ( 9.99 to R$ 9,99), and before update, i turn back the "."

 

$crud->callback_before_update(array($this,'checking_preco'));

 

 

function checking_preco($post_array,$primary_key)
{
    $post_array['preco'] = number_format($post_array['preco'],2,'.', '');
   
    return $post_array;
}

 

 

But, the value on $post_array['preco'] dont have the decimals!!!  "9,99" is only "9" on before_update!

 

Whats o going on? Where i wrong?

 

Sorry for my poor english, and thanks for your time. 

 



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 18 August 2013 - 09:13 AM

Hi there,

My query here is .. what is it you have an entry in the box while you are updating. I know you have 9,99 @column level. But while entering .. what is the value you setting.

Take a dump of the post from firebug and share / have a look @what is the real issue and where



#3 Romac

Romac

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 18 August 2013 - 06:01 PM

Well, if i do a update directly on database with the value "9.99" it ok, when i list with grocery the display is ok, but on update they write "9". Without any modification on column by the user.



#4 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 19 August 2013 - 08:37 AM

well to reach to the proper solution on the same, take a dump of the post from firebug and share / have a look @what is the real issue and where. There we will atleast come to know as what is the value being posted.

Also if possible for you to take the dump of the post_array in your callback method .. if you can get the dump .. it will be easier to analyze and give u solution







Also tagged with one or more of these keywords: callback, decimal

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users