# |
Dec 2nd 2017, 20:05 |
obinoob |
Another thing I see is that errors is empty but the validator message if firing '=( |
# |
Dec 2nd 2017, 20:04 |
obinoob |
*how entities |
# |
Dec 2nd 2017, 20:03 |
obinoob |
dereuromark yes I see but I don't have that deep understanding of entities work at that level seriously :( I get that the registry is not being pulled out of the database it looks like I'm adding a new registry the strange part is that it's not complaining about Addresses and it surely is at the same level as Phones or Emails... |
# |
Dec 2nd 2017, 19:59 |
dereuromark |
you might not need it, just make sure you pull the related records so patching updates those instead of creating new ones. |
# |
Dec 2nd 2017, 19:58 |
obinoob |
dereuromark I've come across "dirty" but I don't have the slightest idea |
# |
Dec 2nd 2017, 19:57 |
dereuromark |
I did some manual looping for my part to work out: https://pastebin.com/fQv0PSVR - Also the $capability->setDirty('features', true); in my case helped :slightly_smiling_face: |
# |
Dec 2nd 2017, 19:56 |
obinoob |
dereuromark I can't find any documented example ... |
# |
Dec 2nd 2017, 19:55 |
dereuromark |
I think you need to use contain to get the related records as well, for patching |
# |
Dec 2nd 2017, 19:55 |
dereuromark |
I had a similar issue when importing csv multiple times |
# |
Dec 2nd 2017, 19:54 |
obinoob |
anyone? |
# |
Dec 2nd 2017, 19:46 |
obinoob |
What can I do in order to update all the association? Because it looks like I'm adding a new registry... |
# |
Dec 2nd 2017, 19:45 |
obinoob |
hello, I been fighting hasMany association for a couple of day now, I can add / delete / list but not update! Validation rules keep firing errors "already in database" for Phones and Emails... https://gist.github.com/obinoob/e72c43d61875a0576c0ee97e121a44ef |
# |
Dec 2nd 2017, 12:27 |
angelxmoreno |
@dereuromark I will check the form helper class sir |
# |
Dec 2nd 2017, 06:07 |
admad |
make the users relogin or implement refresh tokens yourself :slightly_smiling_face: |
# |
Dec 2nd 2017, 04:23 |
prepender |
how do you guys handle expired jwt tokens on mobile apps? do you store their login credentials to refresh the token? i notice most out of the box jwt token solutions dont have resfresh endpoints and I wonder what the assumed method of refreshing would be? |
# |
Dec 2nd 2017, 01:58 |
dereuromark |
angel: did you solve it? passing the form into the formhelper should help, that uses its schema |
# |
Dec 2nd 2017, 00:03 |
obinoob |
back tomorrow have a good night/day to you all cheers :) |
# |
Dec 1st 2017, 23:47 |
obinoob |
I could unsetProperty I guess but not sure how with mass assignment https://github.com/cakephp/cakephp/issues/4288 |
# |
Dec 1st 2017, 23:42 |
phantomwatson |
The SQL statement `DELETE FROM phones WHERE number IS NULL` should do it. |
# |
Dec 1st 2017, 23:40 |
phantomwatson |
But concerning the unwanted database records, you'll need to either remove those manually or write a script that searches through the database and removes them. Just changing CakePHP's validation rules and form-processing logic won't automatically change any existing records in the database. |
# |
Dec 1st 2017, 23:38 |
phantomwatson |
Then to be safe, have some server-side logic that checks that data and returns an error if no phone numbers have been entered. This is just in case the client-side validation fails. |
# |
Dec 1st 2017, 23:36 |
phantomwatson |
You want to make the first phone number field required but not the second one? You'll likely need to make _neither_ of them required in your validation rules, then manually set `$this->Form->control('number', ['required' => true]);` for your first phone number input field. |
# |
Dec 1st 2017, 23:34 |
obinoob |
sorry method :) |
# |
Dec 1st 2017, 23:34 |
obinoob |
? It makes no sense to me that cake has no such future.... |
# |
Dec 1st 2017, 23:34 |
obinoob |
phantomwatson I've found that public function beforeSave method is not triggered from controller but from table... the problem is that beforeSave($event, $entity, $options) { ... } in table has access at one entity at a time, not to all of the entities.... also how can I mark only one phone number as obligatory without refactoring the all database |
# |
Dec 1st 2017, 23:24 |
phantomwatson |
*Answering my own question:* Turns out I should have been using `$this->request->getEnv('FOO')` to read the variable instead of `env('FOO')`. |
# |
Dec 1st 2017, 23:07 |
d-fens |
why doesn't the baked code order by id , iirc that was default in older versions? |
# |
Dec 1st 2017, 23:04 |
phantomwatson |
I'm avoiding `configRequest()` to stay DRY and avoid having to duplicate the other environment variables that are set in this test class's `setUp()` method. |
# |
Dec 1st 2017, 23:00 |
phantomwatson |
In other words, this is my situation: ``` // In test public function testFoo() { $this->_request['environment']['FOO'] = 'bar'; $this->get('/login'); } // In controller public function login() { debug(env('FOO')); // expected: 'bar'; actual: null } ``` |
# |
Dec 1st 2017, 22:27 |
phantomwatson |
In an integration test, I'm using `$this->configRequest(['environment' => ['foo' => 'bar']])` to set an environment variable before a request, but in the controller method that gets executed, the `foo` env var is always the default value, and `configRequest()` doesn't seem to be doing what I intend it to. Does anyone have any advice about setting env vars in an integration test? |
# |
Dec 1st 2017, 22:26 |
angelxmoreno |
something tells me @dereuromark already has the solution hidden somewhere :P |
# |
Dec 1st 2017, 22:26 |
angelxmoreno |
Greetings bakers! I am working with a CakeForm class and I am defining its schema. I feel weird having to change the view when I change the form object in order to add new fields. It feels "uncake-like". Is there an undocumented helper that takes the form object and creates the view using the already defined schema in the Form object? |
# |
Dec 1st 2017, 21:51 |
obinoob |
phantomwatson actually I can only see beforeSave in table and data it will be accessed with $event->getData('entity) https://book.cakephp.org/3.0/en/controllers/components/authentication.html |
# |
Dec 1st 2017, 21:47 |
obinoob |
and my english doesn't help much either |
# |
Dec 1st 2017, 21:46 |
obinoob |
I thought that cake had some key value option to do this kind of work hidden in the book somewhere... |
# |
Dec 1st 2017, 21:45 |
phantomwatson |
It definitely takes some work. Remember to check https://stackoverflow.com/ for answers too. |
# |
Dec 1st 2017, 21:44 |
obinoob |
*I'm |
# |
Dec 1st 2017, 21:44 |
obinoob |
I starting now with events so it is a total new thing for me today i've used for the first time beforeMarshal() I'm alone here man only count with channel help and cake website it's hard some times I take more than a day to achieve some basic stuff! |
# |
Dec 1st 2017, 21:42 |
phantomwatson |
It's okay. This stuff is complicated. |
# |
Dec 1st 2017, 21:41 |
obinoob |
yes I got that I wasn't paying attention I apologise |
# |
Dec 1st 2017, 21:41 |
phantomwatson |
So the code that I posted would normally be wrapped in `if ($this->request->is('post') {}` |