Client Validation for Tabular Input

Hey, guys!

I’ve been searching for this question for a while, but I couldn’t find a good answer so far. Basically, I need a tabular input form with client validation. I’m using the Yii Bootstrap 1.0 extension, but the problem also occurs in CActiveForm. My Yii version is 1.1.10.

Here is the idea: a doctor will fill a prescription that may have N medications. For each medication, we have fields like medication name, dose, frequency, etc. Each field has its rule set in a CActiveRecord.

When I have just one medication, the form works great. But when I repeat the fields for another medication, the client validation stops working. For example, an incorrect value in the first "name" field will display an error message in the second field too.

One problem is that the javascript rules are bound to the element’s id, and they don’t get updated if I set the id property (even the “for” attribute of labels don’t update themselves).

Is there a way to make this work? I’ve found this ZTabularInputManager extension, but I haven’t tested it yet since it seems that it only works with ajax validation. I can throw away the client validation if necessary, but I’d like to know if there is a solution first.

Thanks for the attention!

I think you will have to roll your own but I’m going to watch this to see if anyone has an idea.

There’s another extension that promises a similar but different approach without ajax. You may want to check it out here. I have not yet tested it and don’t know if it’s what you’re looking for.

Another extension that handles multi-step forms and might be useful reference for you is wizard-behavior.

I have found that link before, but I was unsure if the validation would keep working if I just change the id in the elements. Will the javascript code be updated automatically? I’ll give it a try.

I use the Wizard Behaviour on the sign up process, since we can split the process in a fixed number of steps. But here is a bit different, since the doctor may add as many medications as he/she wants.

As I suspected, the javascript code is not updated. The extension is useful and smart to help me with tabular inputs, but apparently there is no client validation.

Well, I can live without it. But if someone finds a good solution, let me know it.