-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
precision 0 #9
Comments
i have a same problem with precision 0 |
Hello ! |
This is just a work around. But if your precision is "0", after you output the field you can add js like in the demo below. $field = $form->field($model, '???'); echo $field->widget(MaskMoney::classname(), [ 'pluginOptions' => [ 'precision' => 0, ... ] ]); $this->registerJs(' $("[name=\''.$field->model->formName().'['.$field->attribute.']'.'\']").on("change", function () { var val = $(this).siblings("input").val(); val = Number(val.replace(/[^0-9\.]+/g,"")); $(this).val(val); }); '); It's not an amazing solution. But it's something. |
@ShadesOB: It's good work around actually. 👍 👍 👍 |
I realised today that this issue also affects loading the page with data. As in what the value is when loading the page. .maskMoney('mask', val); which doesn't work when you have precision 0; .val(val); .maskMoney("mask"); So an update version of my last post would be $this->registerJs(' var input = $("[name=\''.$field->model->formName().'['.$field->attribute.']'.'\']"); input.on("change", function () { var val = $(this).siblings("input").val(); val = Number(val.replace(/[^0-9\.]+/g,"")); $(this).val(val); }); setTimeout(function(){ var input = $("[name=\''.$field->model->formName().'['.$field->attribute.']'.'\']"); input.siblings("input").val(input.val()); input.siblings("input").maskMoney("mask"); },1); '); As a side question. If anyone can tell me how js scopes work in this example I would appreciate it. |
@ShadesOB , Thanks you very much! It worked like a charm 👍 |
hi, i try to implement @ShadesOB solution, but i still don't understand, please advice. how to implement to my code.
|
First up, apologies as I'm on a new (non yii) project and can't test any of There are two problems when helping out with an answer.
But I would try changing: $('#poagen-netto').val(bruto-tarra); => Or doing: $('#poagen-bruto,#poagen-tarra,#poagen-netto').on("change", function But again. I'm not in a position to test this. So only guessing. On Sun, Aug 28, 2016 at 7:10 PM, wilsonxyz [email protected] wrote:
|
Resolved via updates & enhancements to release v1.2.2. Duplicate to #26, #23, #22, #16. |
It's rarely we use decimal in my country. So when I tried
I tried inputting
123456789
, in the textfield it'sRp.123.456.789
, but in the hidden field it's somewhat123456.789
.Did I put wrong config?
The text was updated successfully, but these errors were encountered: