Boolean Validator Dont Work If Javascript Is Disabled [Solved]

boolean validator dont work if javascript is disabled. how can resolve it?

my rules:

array('username, email, password, password_confirm,email_confirm, rules', 'required','message'=>'*'),

array('rules', 'boolean'),

If javascript is disabled, ajax validation and client validation will not work.

There’s no solution for it.

But once you have submitted the form, the server side validation SHOULD work. Do you mean that it also doesn’t work?

yes server side validation dont work.

Could you elaborate the problem a little more in details?

What do you mean by “don’t act”? What is the expected behavior and what do you get instead?

Does it work as expected when javascript is enabled?

Can you provide us with a sample case that reproduces the problem?



  'NewUser' [color="#888a85"]=>[/color]      [b]array[/b] [i](size=7)[/i]       'username' [color="#888a85"]=>[/color] string [color="#cc0000"]''[/color] [i](length=0)[/i]       'email' [color="#888a85"]=>[/color] string [color="#cc0000"]''[/color] [i](length=0)[/i]       'email_confirm' [color="#888a85"]=>[/color] string [color="#cc0000"]''[/color] [i](length=0)[/i]       'password' [color="#888a85"]=>[/color] string [color="#cc0000"]''[/color] [i](length=0)[/i]       'password_confirm' [color="#888a85"]=>[/color] string [color="#cc0000"]''[/color] [i](length=0)[/i]       'verifyCode' [color="#888a85"]=>[/color] string [color="#cc0000"]''[/color] [i](length=0)[/i]       'rules' [color="#888a85"]=>[/color] string [color="#cc0000"]'0'[/color] [i](length=1)[/i]


[/b]In here checkbox is unchecked adn rules value is 0, but NewUser_rules_em_ don’t appear on form while other errormessages appears correctly. I want when the rules value was 0(unchecked) form will don’t validate.

array('username, email, password, password_confirm,email_confirm, rules', 'required','message'=>'*'),

array('rules', 'boolean'),


	<div class="row">

		<?php echo $form->checkBox($model,'rules',array()); ?>

		<?php echo $form->error($model,'rules'); ?>


You’ve misunderstood the boolean validator.

"0" is a valid value for a boolean.


0 is valid for a boolean value, therefore the form always validate.

Make a custom rule:

Custom Rule


Even if changed the checkBox as following:

<?php echo $form->checkBox($model,'rules',array('value'=>1)); ?>

will don’t change in result, still don’t work.

You should read the previous two answers.


dear friends, very thanks for responses

I read those post and i can make custom rules.

I want know where is it used.

API document:

Into your model rules:

public function rules()


        // NOTE: you should only define rules for those attributes that

	// will receive user inputs.

	return array(

                    array('fieldName', 'boolean', 'falseValue'=>'yourFalseValue', 





My mean was these thinks:

How over thanks

I don’t understand you.