Log message #4154569

# At Username Text
# Jun 28th 2018, 16:30 rubenD So if I save, then patch entity and save again, it works. I assume then that default functionality is that cake will only update an existing association, it will not update an association that is being made in the same save procedure.
# Jun 28th 2018, 16:16 rubenD It saves the association, just doesn't update the record. So I pass in clients.0.id and clients.0.mobile. The association is made with the correct ID, but the mobile field for that client remains blank.
# Jun 28th 2018, 16:14 josbeir just pass in the required data
# Jun 28th 2018, 16:14 josbeir should be yeah
# Jun 28th 2018, 16:13 rubenD Hi josbeir, I can't see where my issue is addressed on that page. Is it definitely possible to update an existing record as you save it as an association to a brand new record?
# Jun 28th 2018, 16:12 Duailibe *ask
# Jun 28th 2018, 16:12 Duailibe is possible to make questions about cakephp v2 here?
# Jun 28th 2018, 16:00 josbeir that whole page will get you where you need to be
# Jun 28th 2018, 15:59 josbeir rubenD => https://book.cakephp.org/3.0/en/orm/saving-data.html#converting-request-data-into-entities
# Jun 28th 2018, 15:45 rubenD So the entity being saved is the Company and is a new record. The clients are associated as belongsToMany and are existing records. During this save operation, I am also trying to update the client name, for example.
# Jun 28th 2018, 15:43 rubenD Hi guys - Is there any way to update a record as you save it with a belongsToMany relationship? So Companies have and belong to many Clients. As we create a new company, we save associated clients. Can the client record be updated during this save operation?
# Jun 28th 2018, 14:59 kunalspunjabi oh ok
# Jun 28th 2018, 14:59 josbeir no
# Jun 28th 2018, 14:59 kunalspunjabi @josbeir was that for me? templateVars
# Jun 28th 2018, 14:49 josbeir (y)
# Jun 28th 2018, 14:47 lubos OK. thanks both :slightly_smiling_face: testing
# Jun 28th 2018, 14:47 slackebot4 select, not sure if that works for radio though
# Jun 28th 2018, 14:47 tim ``` $percentages = $this->Products->VatPercentages->find('all', ['order' => ['percentage' => 'ASC']])->toArray(); $vatPercentages = []; foreach($percentages as $percentage) { // We need the percentage value to calculate the prices with JavaScript $vatPercentages[] = [ 'text' => $percentage['name'], 'value' => $percentage['id'], 'data-value' => $percentage['percentage'] ]; }``` That's what I used for a
# Jun 28th 2018, 14:46 josbeir https://book.cakephp.org/3.0/en/views/helpers/form.html#adding-additional-template-variables-to-templates
# Jun 28th 2018, 14:46 josbeir check how RadioWidget.php works internally
# Jun 28th 2018, 14:44 josbeir you can use the templateVars option to set extra suff on the radio element itself
# Jun 28th 2018, 14:44 kunalspunjabi @generitter checking
# Jun 28th 2018, 14:43 josbeir 'radio' => '<input type="radio" name="{{name}}" value="{{value}}"{{attrs}}>',
# Jun 28th 2018, 14:43 josbeir you can override the template of the radio element
# Jun 28th 2018, 14:43 generitter @kunalspunjabi Did you look at beforeRender in components? Possible you removed something doing the upgrade.
# Jun 28th 2018, 14:42 lubos @josbeir re outcome, let's say I have radio output with yes, no and for "no" i need data-error attribute so I can hadle javascript message when that option is selected
# Jun 28th 2018, 14:42 kunalspunjabi @generitter - @josbeir thought this was the problem too but its not. beforeRender gets called. No variables are being passed from my AppController to my views
# Jun 28th 2018, 14:40 generitter @kunalspunjabi isProduction, you might check to ensure the code that was in previous beforeRender calls in you 2x components and what not is still firing.
# Jun 28th 2018, 14:40 josbeir what wou be your ideal outcome?
# Jun 28th 2018, 14:40 josbeir depending on what you want to do
# Jun 28th 2018, 14:40 lubos So not in default template, right? I should create template / widget for this...
# Jun 28th 2018, 14:39 josbeir @kunalspunjabi back to debugging then !
# Jun 28th 2018, 14:39 josbeir @lubos you can change the templates option
# Jun 28th 2018, 14:38 kunalspunjabi @josbeir fixed the issues with the javascript helper, now it's back to the same error! ugh ```Notice (8): Undefined variable: isProduction [APP/View/Elements/seo.ctp, line 16] ```
# Jun 28th 2018, 14:37 lubos So I imagine something like ``` 'type' => 'radio', 'options' => [ 0 => 'No', 1 => [ 'value' => 'Yes', 'class' => 'yes-input' 'data-what' => 'ever' ] ```
# Jun 28th 2018, 14:35 lubos https://book.cakephp.org/3.0/en/views/helpers/form.html#options-for-select-checkbox-and-radio-controls
# Jun 28th 2018, 14:35 lubos FormHelper, is it possible to set html attributes for select options / radio options?
# Jun 28th 2018, 14:32 josbeir have fun !
# Jun 28th 2018, 14:24 kunalspunjabi working on it @josbeir
# Jun 28th 2018, 14:14 generitter Looks like the Core FormHelper class has been extended and the interfaces no longer match.
# Jun 28th 2018, 14:14 josbeir there are quite some differences between cake 1 and 2