# |
Dec 4th 2017, 19:15 |
hmic |
the table the foreign id field is in is the only thing that defines the association - the table that has it, is the belongsTo side, ever, ever, ever. towns hasOne (or Many) addresses in this case |
# |
Dec 4th 2017, 19:15 |
obinoob |
however each address hasOne town_id |
# |
Dec 4th 2017, 19:15 |
obinoob |
ok I've done that, meaning that the column town_id in addresses belongs to towns |
# |
Dec 4th 2017, 19:14 |
hmic |
if it's in the addresses, it's addresses belongsTo towns |
# |
Dec 4th 2017, 19:14 |
obinoob |
Addresses |
# |
Dec 4th 2017, 19:14 |
hmic |
in which table is the town_id field? |
# |
Dec 4th 2017, 19:09 |
obinoob |
hmic I think so, I have a small doubt reading relation between: Addresses "might" have 0 or 1 Towns! Is this not meaning that address should have the following: belongsTo and asOne for town_id ? |
# |
Dec 4th 2017, 19:08 |
hmic |
give it a try |
# |
Dec 4th 2017, 19:07 |
obinoob |
hmic I need to refractor my model relations... I've just notice that I might be missing a few important steps here! Or I might be wrong either... |
# |
Dec 4th 2017, 18:55 |
hmic |
obinoob, paginate addresses table instead of clients |
# |
Dec 4th 2017, 18:50 |
obinoob |
hmic I'm not following... '=( |
# |
Dec 4th 2017, 18:47 |
hmic |
you've got your answers already |
# |
Dec 4th 2017, 18:47 |
hmic |
you dont need to show it again |
# |
Dec 4th 2017, 18:47 |
obinoob |
https://gist.github.com/obinoob/9668db682997c3175ccca2b0a24de257 |
# |
Dec 4th 2017, 18:46 |
hmic |
:D |
# |
Dec 4th 2017, 18:46 |
obinoob |
lol hmic I don't I realize that you have far more important things to do sorry for that |
# |
Dec 4th 2017, 18:45 |
hmic |
do you really think i remeber your model still? :O |
# |
Dec 4th 2017, 18:45 |
hmic |
hint: change your viewpoint to the adresses scope maybe - query this table instead! |
# |
Dec 4th 2017, 18:45 |
obinoob |
*using |
# |
Dec 4th 2017, 18:45 |
obinoob |
hmic I'm it's the same realtional model that you have seen earlier today |
# |
Dec 4th 2017, 18:44 |
hmic |
if its a hasone/belongsto - yes. if it's a hasnmany - no |
# |
Dec 4th 2017, 18:42 |
obinoob |
is it possible to sort data from district->name where Clients hasOne Address->Towns->Districts ? I've tried the following: https://gist.github.com/obinoob/83db63ee87a1b4b39eb53b211fd9f6ad |
# |
Dec 4th 2017, 17:21 |
abik |
thanks |
# |
Dec 4th 2017, 17:20 |
admad |
yes, $this->Foo->Associated->setSaveStrategy() |
# |
Dec 4th 2017, 17:18 |
abik |
can I do it on the fly ? |
# |
Dec 4th 2017, 17:13 |
admad |
abik: set "saveStrategy" for the association to "replace" |
# |
Dec 4th 2017, 17:11 |
abik |
I want cake replace the shops data not (insert)append the new shops. |
# |
Dec 4th 2017, 17:10 |
abik |
$customer = $this->Customers->patchEntity($customer, $this->request->getData(), ['associated' => ['Shops' => ['saveStrategy' => 'replace']]]); |
# |
Dec 4th 2017, 17:10 |
abik |
but when edit form save it add the new shop to shops table, I want first it remove the shops and then add new shops on update. |
# |
Dec 4th 2017, 17:08 |
abik |
it saved ok. |
# |
Dec 4th 2017, 17:08 |
abik |
['name'=>'XYZ','shops'=>[]] |
# |
Dec 4th 2017, 17:08 |
abik |
I am working on customer from that save customer and its shops, |
# |
Dec 4th 2017, 17:04 |
hmic |
needs a little glue on the cake side though, as it's not really designed to work with creators. but its very clean and well possible to do so |
# |
Dec 4th 2017, 17:03 |
hmic |
angelxmoreno: just write a custom creator class to inject the data to the formhelper, validator, and so on... |
# |
Dec 4th 2017, 16:59 |
angelxmoreno |
@admad yep, i see that now. I want a single source of truth for my form's data, validation and presentation to maximize reusability. I extended the Form class and Form helper. gonna try to have something to demo because I think it is very useful. |
# |
Dec 4th 2017, 16:56 |
admad |
if you want to be DRY make a helper |
# |
Dec 4th 2017, 16:55 |
admad |
these are the only valid keys |
# |
Dec 4th 2017, 16:55 |
admad |
https://github.com/cakephp/cakephp/blob/master/src/Form/Schema.php#L35 |
# |
Dec 4th 2017, 16:54 |
admad |
@angelxmoreno adding label and placeholder to Form/Schema fields won't do anything |
# |
Dec 4th 2017, 16:52 |
angelxmoreno |
well damn |
# |
Dec 4th 2017, 16:52 |
admad |
crud, crud-view has nothing related to `Form` |