On signup, I need a certain message, but for some reason, it fails to show my message.
please help
I have the following rules:
['acordul_tc', 'required', 'on' => ['register']],
['acordul_tc', 'integer', 'max' => 1, 'message' => 'my test message'],
and the html:
<div style='position:relative; float:left; padding:5px;'>
<div style='float:left; padding:5px;'>
<?php
echo $form->field($model, 'acordul_tc',
['options' => ['tag' => 'span',],
'template' => "{input}"])->checkbox(['checked' => false]);
?>
</div>
<div style='float:left; padding:5px;'>
<?php
echo \Yii::t('user', 'acordul_tc_start') .
Html::a(Yii::t('diverse', 'Termenii si Conditiile'),
['site/terms-and-conditions']) .
\Yii::t('user', 'acordul_tc_end');
?>
</div>
</div>
<div class="col-lg-12">
<?php
echo $form->field($model, 'acordul_tc',
['template' => "{error}"])
->error();
?>
If you want to show error message when checkbox is not checked, try this rule
['acordul_tc', 'required', 'on' => ['register'], 'requiredValue' => 1, 'message' => 'my test message']
This means that the attribute is required and must be equal to 1, else display error with your message.
Below is the code change need to be done on FORM to get expected output for End User.
echo $form->field($model, 'acordul_tc',
['options' => ['tag' => 'span'],
template' => "{input}"]
)
->checkbox(['checked' => false, 'required' => true]);
Below is the image that explains all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With