Compulsory fields in views only

I have certain columns which are not compulsory normally but, in certain forms(views) which take data for those fields I want them to show as compulsory, There are just one model,one controller and many views.

I want to make them compulsory in the views.

How can I do that?

take for example one field




	<div class="row">

	<?php echo $form->labelEx($zzz,'aaa'); ?>

	<?php echo $form->textArea($zzz,'aaa'); ?>

	<?php echo $form->error($zzz,'aaa'); ?>

	

	</div>

	

	

I have one more code I would like to make compulsory only in view that is Terms and Conditions checkbox




	<div class="row">

	<label for="terms"> I agree to the Privacy Policy and Terms and Conditions.*</label>

	<?php // echo $form->checkBox($details,'te'); ?>

	<?php // echo $form->error($details,'te'); ?>

	

	</div>

	

How will I do this

Can`t you achieve it via "on" attribute of rules.There you can specify what are the actions that particular validation rule should apply.

My Terms and Conditions check box does not have a value in database, how will I validate it

Just add a variable to maintain "terms and conditions" value to model class.No need db field.

ex:

in model


$terms_and_cond=’’;

in view


<div class="row">

<?php echo $form->labelEx($model,‘terms_and_cond’); ?>

<?php echo $form->checkBox($model,‘terms_and_cond’); ?>

<?php echo $form->error($model,‘terms_and_cond’); ?>

</div>