Good morning,
I need advice on how to use currency format, in my case Euro.
In web.cfg I put, as the guide:
'formatter' => [
'dateFormat' => 'dd.MM.yyyy',
'decimalSeparator' => ',',
'thousandSeparator' => ' ',
'currencyCode' => 'EUR',
],
This allows me to use:
- in GridView
[
'attribute' => 'amount',
'format' => 'currency'
],
- In DetailView
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'amount:currency',
],
]) ?>
Regarding ActiveForm instead I’m a bit confused. I tried the plugin yii2-money, but honestly his use is a bit unnatural. So I believe that the only alternative is to use the widget MaskedInput.php.
I saw that it can be used directly in ActiveField:
* <?= $form->field($model, 'from_date')->widget(\yii\widgets\MaskedInput::className(), [
* 'mask' => '999-999-9999',
* ]) ?>
I think I should use an alias, but I have difficulty on how to implement it. If I were to use jquery.inputmask directly, I think I should write something like:
$("#amount").inputmask("decimal",{
radixPoint:",",
groupSeparator: ".",
digits: 2,
autoGroup: true,
prefix: '€'
});
but I have some difficulty on how to do the same with MaskedInput. Can you show to me an example? Or, there is a better system for the same purpose?