# |
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` |
# |
Dec 4th 2017, 16:50 |
angelxmoreno |
googling |
# |
Dec 4th 2017, 16:50 |
angelxmoreno |
?!?! |
# |
Dec 4th 2017, 16:50 |
hmic |
angelxmoreno: maybe look at crud+crud-view |
# |
Dec 4th 2017, 16:48 |
angelxmoreno |
thus, I am still forced to define my fields one by one in my view. too much duplicate code IMO. I must fix this |
# |
Dec 4th 2017, 16:47 |
slackebot2 |
'placeholder'=>'Your Full Name' ]); return $schema; } |
# |
Dec 4th 2017, 16:47 |
angelxmoreno |
greetings bakers! So, apparently this does not work: ``` class RegisterTenantForm extends Form { /** * Builds the schema for the modelless form * * @param \Cake\Form\Schema $schema From schema * @return \Cake\Form\Schema */ protected function _buildSchema(Schema $schema) { $schema->addField('name', [ 'type' => 'string', 'label' => 'Name', |
# |
Dec 4th 2017, 15:59 |
neon1024 |
Ah, it seems because it’s not part of PSR7 |
# |
Dec 4th 2017, 15:59 |
neon1024 |
Hm, yeah I didn’t check |
# |
Dec 4th 2017, 15:58 |
inoas |
aliases? |
# |
Dec 4th 2017, 15:54 |
neon1024 |
#vpntypingdelaysucks |
# |
Dec 4th 2017, 15:53 |
neon1024 |
If Cake\Network is now Cake\Http, why can I stioll throw a Cake\Network|noTfoundException? |
# |
Dec 4th 2017, 15:45 |
admad |
@birdy247 twig templates definitely work :slightly_smiling_face: |
# |
Dec 4th 2017, 15:33 |
inoas |
https://www.youtube.com/watch?v=q8wueg2hswA#t=46m <3 |
# |
Dec 4th 2017, 15:24 |
birdy247 |
but it wasnt used |
# |
Dec 4th 2017, 15:24 |
birdy247 |
@admad I did try creating the twig template |
# |
Dec 4th 2017, 15:15 |
admad |
hehe |
# |
Dec 4th 2017, 15:13 |
hmic |
:D |
# |
Dec 4th 2017, 15:13 |
hmic |
theres even a word for that - neon1024ing |
# |
Dec 4th 2017, 15:13 |
admad |
often just asking helps you spot your mistake |
# |
Dec 4th 2017, 15:12 |
admad |
if you say so :slightly_smiling_face: |
# |
Dec 4th 2017, 15:03 |
johnnypepperoni |
I'm an idiot |
# |
Dec 4th 2017, 15:03 |
johnnypepperoni |
ups |