Many Many Relation With Value

I have following data struktur


+---------+		+-----------------+		+---------+

|user     |		|user_has_keyfact |		|keyfact  |

+---------+		+-----------------+		+---------+

|id       |		|user_id          |		|id       |

|user     |		|keyfact_id       |		|keyfact  |

+---------+		|keyfactValue     |		+---------+	

				+-----------------+

relation:

‘keyfacts’ => array(self::MANY_MANY, ‘Keyfact’, ‘user_has_keyfact(user_id, keyfact_id)’),

when generation a checkboxlist everything is fine. save/update is working.

But when I try to use textfields instead of it is impossible for me to generate a correct html syntax so the data can be saved. (with

Is it possible in yii to do it woithout writing everything by myself? (i mean the database update, delete statements) or maybe someone has a better idea for my data structure?

You may add one more relation, to user_has_keyfact, which you may use it to select keyfactValue.

Sometimes this structure is a right choice (if you can’t store keyfactValue in keyfact table).

The idea behind the structure is to store values like age, wight, height, etc

So I think a multicolumn table make no sense.

Hi,

Do you mean replacing the checkboxList with textfields ? What is then the html generated (and the data send by the request) ?

Or is it only for the keyFactValue ? (and same questions as above).

keyfact_id represents the type of the data, e.g. age

keyfactValue is the age

So yes, i want to replace the checkbox with an input field oder maybe not replace but create an additional input field for the value.

To make it more difficult I also want to user Dropdowns for information like Haircolor etc.

OK, understand now:

you want to add additional informations, wich are defined in keyfact table, to a user "profile" through the association table user_has_keyfact.

Checkboxes are for associating User models to Keyfact models. I can’t understand why you want to replace them with texfields.

Textfields (or dropdowns) have to be used for populating the "keyFactValue" in the association table.

Have you got any unit tests in place for these models ? If so … can I have a look at them ?

Hi how did you make save/update work in your case. i have a problem saving and updating checkboxlist()

I have a two models, facilities and hotels. I want when creating a hotel i can display list of checkboxes where i can then select the facilities for that hotel, save in hotels table column facilities in this format 1,3,5,7,8,10,…

I also want when i am editing or updating to be able to view the previously selected facilities checked.