Yii Framework Forum: Masked Input - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Masked Input Masked Input for money Rate Topic: -----

#1 User is offline   jorge sequeira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 81
  • Joined: 05-February 13
  • Location:PORTUGAL

Posted 11 May 2017 - 11:04 AM

Hi, I'm trying to establish a masked input for money. This code almost works. The only problem is that when saving to the database the decimal part is forgotten. Ex: 12,76 is stored as 12.

            <?= $form->field($model, 'valor')->widget(\yii\widgets\MaskedInput::className(), [
            'clientOptions' => [
                'alias' => 'decimal',
                'radixPoint' => ',',
                'digits' => 2,
                'groupSeparator' => '.',
            ],
            ]) ; ?>


This is probably a stupid little thing but I can't figure out what's happening.
Can anyone please help?
0

#2 User is offline   Fábio Sales 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 105
  • Joined: 20-January 11

Posted 17 May 2017 - 12:10 PM

Hi Jorge,

You need to replace the decimal separator (comma per point). In the model`s class, you can do this through the method "onBeforeSave()".
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users