Closed SDKiller closed 9 years ago
can you show the form code that produces this problem?
<?php $form = ActiveForm::begin([
'id' => 'add-phone-form',
'action' => ['customer/add-phone'],
'fieldConfig' => ['template' => "{input}\n{error}"],
]); ?>
<?= $form->field($model, 'phone')->widget(MaskedInput::className(), [
'mask' => '+7 (999) 999-9999',
]) ?>
<?= $form->field($model, 'comment')->textInput() ?>
<?= $form->field($model, 'set_primary')->checkbox() ?>
<?= $form->field($model, 'id')->hiddenInput(); ?>
<?php ActiveForm::end(); ?>
I've already met this sutuation several times - you cannot rely on elements ordering in html form
You can. It always come in right order to backend with classic submit.
when using something like jQuery.serialize(), .serializeArray() in ajax request
Its jQuery
issue. Just use checkbox()
helpers with 'unselect' => false
if you use jQuery
.
Its jQuery issue. Just use checkbox() helpers with 'unselect' => false if you use jQuery.
I don't consider it jQuery issue.
Simultaneos submitting of 2 opposite input values in hope that they will come to server in correct order is bad by design as it initially creates prerequisites for ambiguous situations.
Anyway, its a proposal, I'd better use inputs without such addons and fix my model load()
to specially handle certain attributes.
Simultaneos submitting of 2 opposite input values in hope that they will come to server in correct order is bad by design as it initially creates prerequisites for ambiguous situations.
Such approach is widely used 10 or more years already (not only in Yii) and nobody have any troubles with that.
It can result ambiguous situation when processing request - finally 'uncheck' values may overwrite 'checked' (especially when using something like
jQuery.serialize()
,.serializeArray()
inajax
request - I've already met this sutuation several times - you cannot rely on elements ordering inhtml
form).I think
yii.activeForm
could care of it and make 'uncheck' disabled if it's 'master' checkbox (don't know how to call it correct) is checked and vice versa.