yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

yii2 enableClientValidation not working with wysiwyg #7495

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi guys,

in model I set

public function rules()
{
    return [
        [['subject', 'content'], 'required']
    ];
}

and setting form :

$cowid = \Yii::$app->request->get('id');
 $model = new SendmailForm();
 $form  = ActiveForm::begin([
           'id'      => 'sendmail-form',
           'action' => '#',
           'enableClientValidation' => true,
           'validateOnSubmit' => true,
           'enableAjaxValidation' => false,
           'options' => [
                 'class'   => 'form-horizontal form-bordered',
              ],
            'fieldConfig' => [
                        'horizontalCssClasses' => [
                            'label' => 'control-label',
                        ],
                    ],
                ]); 

and textarea I used wysiwyg

     $form->field($model, 'content', [
          'template' => "<div class='col-md-3'>{label}</div><div class='col-md-9'>{input}</div>\n{hint}\n{error}",
           'selectors' => ['input' => '#textarea-wysiwyg']])
           ->textArea(['rows' => '6', 'class' => 'form-control textarea-editor', 'id' => 'textarea-wysiwyg'])

but it seems enableClientValidate is not working with wysiwyg

Could you guys please help me ?

Thanks in advance .

samdark commented 9 years ago

I guess it's working but since most WYSWIG editors are hiding original field, validation error is hidden as well.

samdark commented 9 years ago

It all depends on the editor.

samdark commented 9 years ago

I don't think we're able to fix it for all possible editors at framework level.