Php Yii define form field validation outwith model

I’m using yii framework in my current project. I have a page with a form (submitting to database) which defines the required fields in the rules of the model - as standard. On this page, I also have a dynamic form I’ve built, as a component which pulls additional fields in.

However, I need to be able to also define some of these as required fields. Is there any way of defining required fields outside of the model?

for example there is a dynamicform component that includes these fields.


if ($attr['required'] === 1){

                $attr['requiredfields'] = array('required' => true);

            }else{

                $attr['requiredfields'] = '';

            }

            // Per type input            

            // 'type'=>'text|radio|textarea|select'


            


            echo CHtml::label($attr['name'], $attr['formname'],$attr['requiredfields']);


            if ($attr['type'] == 'text') {

                echo '<div class="form-group' . $attr['required'] .'">';

                echo CHtml::textField($attr['formname'], $attr['value'], $attr['htmlOptions']);

                echo '</div>';

            } 

And this is used in my form like so


<?php

$varform = new DynamicForm();

$varform->attributes = $user->getDynamicFormConfig();

$varform->model_name = 'user';

echo $varform->run();

?>