mulle2000
(Matthias Boese)
November 13, 2012, 10:53pm
1
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?
yugenekr
(Yugenekr)
November 14, 2012, 9:38am
2
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).
mulle2000
(Matthias Boese)
November 14, 2012, 10:12am
3
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.
luc
(Luc Pfister)
November 14, 2012, 6:20pm
4
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).
mulle2000
(Matthias Boese)
November 14, 2012, 6:53pm
5
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.
luc
(Luc Pfister)
November 14, 2012, 7:43pm
6
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.
vicsilver
(Victor G Silver)
December 14, 2012, 6:25pm
7
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?
Have you got any unit tests in place for these models ? If so … can I have a look at them ?
khanz82
(Anthony)
April 15, 2013, 2:04pm
8
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?
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.