Kartik widget NumberControl renderAjax() doesn't update value

Hello,

I use it in a partial _formUpdate.php to update after ajax call.

<?= $form->field($model, 'amount')->widget(NumberControl::class, [
'readonly' => 'true',
'maskedInputOptions' => [
'digits' => 2,
'digitsOptional' => false, // Will force 20.00 instead of 20
'suffix' => ' $',
'allowMinus' => false,
'rightAlign' => false,
]]) ?>

Controller:

return $this->renderAjax('_ajaxUpdate', ['model' => $model, 'form' => $form]);

But value is not set in the widget. I know that the same problem appears with Kartik DateControl and that we need to call .kvDatepicker after the POST return.

Is the same approach applied? What is the function we should call? Can’t find it.

Thank you.

I am not too familiar with @kartikv extensions. However it does appear in the documentation that you will need to have additional options passed to your widget.

Hope this helps you.

Where did you read something about it?

I just noticed it in the usage section in the code examples. The code examples showed some additional parameters passed to the widget that you did not have. Not sure if it helps though.

The only solution found was to update it manually in JS:

        document.getElementById("slinvoiceline-amount-disp").value = amount;
        document.getElementById("slinvoiceline-amount").value = amount;

But you need to do it on two elements (by design in widget).

1 Like