# |
Jul 20th 2021, 12:08 |
paolo.bragagni |
so in this way? $this->Form->hidden('books',['value' => ['categories' => [['id' => 'value']]]]) |
# |
Jul 20th 2021, 12:05 |
paolo.bragagni |
I check it all |
# |
Jul 20th 2021, 12:04 |
paolo.bragagni |
yes |
# |
Jul 20th 2021, 12:04 |
slackebot2 |
more categories. |
# |
Jul 20th 2021, 12:04 |
ndm |
So it's actually `hasMany`, not `belongsToMany`? And you create a new books record, meaning there is no existing associated data that would need to be modified, and only this one hidden category should be added? Then the field name format would be `categories.0.id` (which translates to `['categories' => [['id' => 'value']]`). But you might get into trouble if there possibly also is a visible control where users can choose one or |
# |
Jul 20th 2021, 11:59 |
paolo.bragagni |
(in my old cake2 project echo "\t\t\t echo \$this->Form->hidden('{$assocName}', array('hiddenField' => true, 'value'=> \$f_id));\n"; worked...) |
# |
Jul 20th 2021, 11:58 |
paolo.bragagni |
everything is working but the add, because when I add a book from that view it has to select category=2 (in hidden field) |
# |
Jul 20th 2021, 11:57 |
paolo.bragagni |
I've done a bake template that build that in the 'view' view |
# |
Jul 20th 2021, 11:56 |
paolo.bragagni |
books (libri) habtm categories |
# |
Jul 20th 2021, 11:56 |
paolo.bragagni |
|
# |
Jul 20th 2021, 11:55 |
paolo.bragagni |
my goal is this (call me crazy) |
# |
Jul 20th 2021, 11:54 |
paolo.bragagni |
I have the value already in the view |
# |
Jul 20th 2021, 11:53 |
dereuromark |
Right before saving :) |
# |
Jul 20th 2021, 11:51 |
paolo.bragagni |
:S |
# |
Jul 20th 2021, 11:41 |
dereuromark |
Most of hidden fields could Actually be added directly in Controller. Removes usually some of the tempering and complexitity vectors |
# |
Jul 20th 2021, 11:37 |
paolo.bragagni |
in Books 'add1' view I'd like to save one specific category |
# |
Jul 20th 2021, 11:36 |
paolo.bragagni |
Books has many Categories |
# |
Jul 20th 2021, 11:20 |
ndm |
The `_ids` key is not ment to hold a flat value, but an array of values. You probably need to be a bit more specific as to where exactly in your associated data you want to store something, and what that something actually looks like (data structure wise). |
# |
Jul 20th 2021, 10:54 |
paolo.bragagni |
I mean I'd like to save a specific value with an hidden field |
# |
Jul 20th 2021, 10:25 |
paolo.bragagni |
I'd like to save $return['returncontrollerid'] |
# |
Jul 20th 2021, 10:24 |
paolo.bragagni |
echo $this->Form->hidden('{{ assocData.property }}._ids', ['value' => $return['returncontrollerid']]); |
# |
Jul 20th 2021, 10:24 |
paolo.bragagni |
hi how to save specific value in form BelongsToMany? |
# |
Jul 20th 2021, 10:08 |
dereuromark |
here it is twice as important to check that all incoming values are properly sanitized though. and there is no room for "injection" of any kind of data. |
# |
Jul 20th 2021, 09:58 |
dereuromark |
if it is just about simple boolean toggles, I usually also just use updateAll() as atomic operation. Simpler if you don't need validation or alike on top. |
# |
Jul 20th 2021, 09:53 |
erwane |
$article->set($fieldName, $value) |
# |
Jul 20th 2021, 09:48 |
kupe3b |
thanks. which function can i call instead of `$article->published=1` for example (in case i pass the field name as an argument)? |
# |
Jul 20th 2021, 09:45 |
dereuromark |
field name can just be the argument, yes |
# |
Jul 20th 2021, 09:44 |
dereuromark |
that methods looks easily breakable, as publish can now also unpublish.. |
# |
Jul 20th 2021, 09:32 |
kupe3b |
hi, I have a very simple method to switch a yes/no field: ``` public function publish($id) { $article = $this->Articles->get($id); $article->published=!$article->published; $this->Articles->save($article) }``` but how can i change it to accept the field name as an argument? `public function publish($id, $fieldName='published')` to be able to change state of the other yes/no fields from `articles` table? |
# |
Jul 20th 2021, 08:14 |
ndm |
What I ment was... don't use WSL, try a dedicated virtual machine. |
# |
Jul 20th 2021, 08:09 |
brandon |
I can't seem to find any error logs or anything so I am not sure where it is even getting stuck to try to remedy it. |
# |
Jul 20th 2021, 08:00 |
paolo.bragagni |
yes. it works rerunning bin/cake bootstrap install |
# |
Jul 20th 2021, 07:58 |
brandon |
Is there a way to make the changes without rector? |
# |
Jul 20th 2021, 07:55 |
rudy1976s |
@greg138 I have a fixture with a json field which contains some values: when I run the test on that table, the json field is not properly read |
# |
Jul 20th 2021, 07:48 |
paolo.bragagni |
(trying..) |
# |
Jul 20th 2021, 07:35 |
paolo.bragagni |
I have to rerun bin/cake bootstrap install ? |
# |
Jul 20th 2021, 07:30 |
ndm |
@brandon tag |
# |
Jul 20th 2021, 07:30 |
paolo.bragagni |
hi. I've updated from 3.0.1 to 3.1.1 and it doesnt find css |
# |
Jul 20th 2021, 07:30 |
ndm |
Try running it in a fresh linux based VM, from my experience that's your best chance. Rector is a little wimp that already breaks when it hears the wind blowing. |
# |
Jul 20th 2021, 07:27 |
ndm |
Rector not working? I am shooketh! SHOOKETH I say! |
# |
Jul 20th 2021, 07:06 |
slackebot2 |
--working-dir='/mnt/d/Programming/PHP/vintage-lib/src' '/mnt/d/Programming/PHP/vintage-lib/src'``` I have tried this both in and out of WSL. Not sure what it is doing or what I can check. Any ideas? |