Issues

Issue #27 resolved

Error message for checkBoxControlGroup

Tomasz Kane
created an issue

Model:

<?php
class User extends Model
{
    public $acceptRules;

    public function rules()
    {
        return array(
            array('acceptRules', 'compare', 'compareValue' => 1, 'on' => 'register', 'message' => Yii::t('msg', 'Accept rules fail')),

Controller:

<?php
public function actionRegister()
    {
        $this->layout = '//layouts/login';
        $user = new User('register');
        $userAddress = new UserAddress('register');
        $this->performAjaxValidation([$user, $userAddress]);

        if (isset($_POST['User']))
        {
            $user->attributes = $_POST['User'];
            $userAddress->attributes = $_POST['UserAddress'];
            if ($userAddress->validate() && $user->save())
            {
                $userAddress->user_id = $user->id;
                $userAddress->save();

                $user->login();
                $this->currentUser()->setFlash(BSHtml::ALERT_COLOR_SUCCESS,  Yii::t('msg', 'Register successful'));
                $this->redirect(Yii::app()->homeUrl);
            }
        }

        $this->render('register', array(
            'user' => $user,
            'userAddress' => $userAddress,
        ));
    }

Theme/view:

<?php $form = $this->beginWidget('bootstrap.widgets.BsActiveForm', array(
    'id' => 'user-form',
    'enableAjaxValidation' => true,
    'enableClientValidation' => true,
    'focus' => [$user,'email'],
    'clientOptions' => [
        'validateOnSubmit' => true,
    ],
)); ?>

<?= $form->checkBoxControlGroup($user, 'acceptRules'); ?>
<?= BSHtml::submitButton(Yii::t('label', 'Submit'), ['class' => 'btn btn-lg btn-primary']); ?>

After "submit" checkbox html code is:

<input type="checkbox" value="1" id="User_acceptRules" name="User[acceptRules]" error="&lt;p id=&quot;User_acceptRules_em_&quot; style=&quot;display:none&quot; class=&quot;help-block&quot;&gt;&lt;/p&gt;">

"P" tag as value of "error" attribute. It's bug or I do something wrong?

Comments (4)

  1. Log in to comment