Closed GoogleCodeExporter closed 9 years ago
Ok, fail.. In the views calling FullCrudCode::generateValueField() we don't use
the relations of the model, but loop and handle things using the table schema
and its columns.
This means that the incoming column namn that I thought I could use in
generateValueField() is 'country_id' instead of the relation name 'countries'.
Question: Why is it the table schema that is used to generate output/fields
instead of the model's attributes and relations? The latter seem much more
appropriate, both naturally and especially considering that what the user has
defined as attributes and relations in the model is what they want to have
fields for in their crud forms -- not necessarily all columns.
So, as I understand it right now (without having gone through ALL the code)
there are two options:
1) Either keep the table *schema* as the base for all the work in view
generation, and in FullCrudCode::generateValueField() loop through the
relations in order to find the relation that matches the given column, and use
that relation to get the class name of the related model.
2) Or, redo the view stuff so that we don't base things on the table schema but
rather the model's attributes and relations.
Original comment by l...@finalresort.org
on 5 Aug 2010 at 12:00
Ok, I worked around this for now, because I really have to get going with my
project. I did it by doing the following to get the related model inside
FullCrudCode::generateValueField():
foreach($model->relations() as $relation) {
if($relation[2] == $column->name) {
$fmodel = CActiveRecord::model($relation[1]);
}
}
However, it's not pretty, and I still think we should discuss the fact that
everything is centered around the table schema instead of attributes and
relations.
I also noticed that in the generated views we get things like:
CHtml::listData(Prefix__country::model()->findAll(), 'id',
'creation_timestamp') instead of the right class name in there, and this too is
of course because everything uses table schema..
Maybe my specific problem could've been solved using table prefixes, I haven't
tried that. I should.
Original comment by l...@finalresort.org
on 5 Aug 2010 at 12:28
These issues should be fixed with r113
Original comment by schm...@usrbin.de
on 16 Sep 2010 at 10:18
Original comment by thyseus
on 17 Sep 2010 at 8:29
Original issue reported on code.google.com by
l...@finalresort.org
on 4 Aug 2010 at 11:50