I was following the yii blog example and was not sure if I missed a step or if there is another alternative than having to declare constants for the values in the lookup table. As I understand it, the lookup table follows a EAV or OTLT concept. For a table with only a few types such as the lookup table example, declaring constants in the model may be fine but as for a table that may include many values (i.e product attributes), it is impractical to declare all possible values as constants. Any ideas or possible alternative solutions?
In the Yii blog tutorial under the section, "Customizing Post Model" (link: http://www.yiiframework.com/doc/blog/1.1/en/post.model), there is a subsection titled, "4. Representing Status in Text". Within this section the author describes the table, "tbl_lookup" which contains status values for the Comment table and the Post table. After modifying the Lookup model class in order to access the text values(as oppose to the integer values), the author also modifies the class Post extends CActiveRecord with the following:
My question above refered to the fact that it looks as if I have to declare constants in order to get a drop down to display the correct values whenever a database table follows an Entity-Attribute-Value format.
In searching other forums, I found the following could possibly work: