Yii Framework Forum: A Validation Issue On Current Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

A Validation Issue On Current Yii Dealing with several nested models validation rules.

#1 User is offline   mem 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 16-December 11

Posted 30 April 2013 - 05:28 AM

I'm not a proficient Yii programmer myself, not even a OOP guru.
So, and first of all, I must say, or repeat what many others have said:
"You can, perhaps, do almost everything in Yii, if you are able to extended and tweak it to your needs."
Again, I'm not Yii proficient, neither OOP guru, but I do believe, this last statement is true.

Despite this, however, I do understand that they should exist certain things that, for their common nature, shouldn't not require such a need for tweaks.

Here's our small history/experience:


We have start this project development over Yii, and we are stuck at the moment due to application design constrains.

The point, at this very beginning, was to create a form (yes, one single, form), that should allow a team to register her self. Each team can have several members, so when you insert the team, members should also be inserted, either 1, or N members. So, 1-N relationship.

Yes, we know about all the forums posts regarding "tabular" validation, and stackoverflow a lot about this, and wikis, and Yii articles regarding similar situations.
And even if you may think, "yeah that can be done!", PLEASE, without wanting to be arrogant: try it yourself first, and then tell us if you have actually been able to do it.

On a ideal design prespective immo, here's the points:
1 - CActiveForm usage on both, main _form and partials inside;
2 - Each member should be a partial;
3 - Each member should be loaded via ajax;
4 - Each member should be validated using their model rules() method;
- so that we can benefit from (consistency server-and-client side, scenario usage, easier Yii::t() integration...)
5 - Working with either Ajax Validation or Client Side validation set to true;

While this may sound simple, truth is, achieving something like this is not possible at the moment.

Re-struture the "validation" classes in order to work on "nested" models scenarios, should be something that, as far as I can tell, would be a very important step to take on Yii 2.0;

Again. I'm not saying it's not possible. But it's clearly as well, not "out of the box" either.

K. Regards,

#2 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 572
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 01 May 2013 - 02:30 AM

I didn't get where the problem is exactly. Sure, tabular input is a bit more complex than a simple form but that can not be changed.
Would be great if you could give more details about what you'd like to see in yii2 that helps with tabular input.

There are already very cool things that make it easy to work with tabular input:


#3 User is offline   mem 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 16-December 11

Posted 01 May 2013 - 06:09 AM

I can't really go into specifics.
But if we could:

1) setup our models with the relations; (has many, belongs to etc...);

2) instantiate on your actions (create() etc...) the models that should be used;

3) setup a form with CActiveForm;
- With clientSide validation enabled;

4) setup our child partials views if needed; (without the need to use chtml on those and keep the same $form->error sintax inside those partials);

And once we load that form, CActiveForm could deal with the validations on those fields an also the (inner) validations of N child partials inside:
that would be nice.

Atm, this seems to be possible only with a LOT of extending work.

Does this makes sense to you?
I'm aware this implies design decisions on CActiveForm implementations on Yii side. But I can't really tell what precisely.

I advocate in favor of such change, because I do believe, those are very common scenarios and, because of that, we should make what is common easier to achieve.

Either using CActiveForm alone, or the form builder, (or simplify this and just keep one of those), the 1-4 process below could be, perhaps, used.

Actually, "Tabular input", as a concept, seems strange atm.

Perhaps it shouldn't be such a specific concept, and just be part of an "option" for a "multi model form" thing.


Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users