Thursday, May 22, 2014

Validate Dynamic Forms

I am building a questionnaire where the user can add questions to a form (either yes or no or text answer response)

So the Question has id, quiz_id, question, type (text or true / false),

 

But how would you validate this?

 

In the view I simply do a foreach ($questions as $question){

echo $this->Form->input($question['question']['id'], array(

                                                'label' => $question['Question']['question'],

                                                'type' => $question['Question']['type'],

                                                'div' => false));

 

But how do you validate this since model validation will not know these input / field names

The fieldname will be dynamic.

 

Thanks,

 

Dave

 

 

 

No comments: