# |
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 |
# |
Jun 28th 2018, 14:13 |
josbeir |
you should fix al those errors |
# |
Jun 28th 2018, 14:13 |
josbeir |
thats a good thing |
# |
Jun 28th 2018, 14:13 |
kunalspunjabi |
@josbeir removing the javascript helper actually throws more errors ```Strict (2048): Declaration of MyFormHelper::beforeRender() should be compatible with Helper::beforeRender($viewFile) [APP/View/Helper/my_form.php, line 12] ``` in addition to what I was seeing earlier. Not sure of a fix but Im investigating |
# |
Jun 28th 2018, 14:11 |
generitter |
I’m writing some test code to verify a route. I’m working in a plugin, the plugin has routes. Does anyone know how to load the routes in my config for the test? The Test results I’m extending Cake TestCase. |