# |
Jun 7th 2019, 08:21 |
dereuromark |
i think he means the literal field in the DB, probably he has requirePresence activated too eagerly. |
# |
Jun 7th 2019, 08:19 |
conehead |
I don't really get what you mean. DisplayField is only used for outputting data? |
# |
Jun 7th 2019, 08:15 |
ondrej.nedvidek |
Table displayField. When set the field is required, but for my case I generate it in beforeSave. Any idea how to disable validator for this field? Nedvajz has many questions today, ha ? 8) |
# |
Jun 7th 2019, 07:07 |
conehead |
cakephp will handle it |
# |
Jun 7th 2019, 07:07 |
conehead |
@liaogz82 Just save the date-time object |
# |
Jun 7th 2019, 07:01 |
liaogz82 |
how does one save time for cakephp? |
# |
Jun 7th 2019, 06:53 |
ondrej.nedvidek |
Anyone who is interested: `$this->Crud->action()->saveOptions(['validate' => 'admin']);` |
# |
Jun 7th 2019, 06:24 |
ondrej.nedvidek |
Does anyone know how to set 'validate' to different set of rules in CRUD validate: https://book.cakephp.org/3.0/en/orm/validation.html#using-a-different-validation-set CRUD: https://crud.readthedocs.io/en/latest/ |
# |
Jun 7th 2019, 05:38 |
conehead |
Hm I don't really get it. I am trying to keep the `_joinData`. It says `[dirty] => [_joinData => true]`, but there were no changes and the `[original] => ['_joinData']` and the `['_joinData'] is equals. Because of this, the joinData is created a second time |
# |
Jun 7th 2019, 04:51 |
conehead |
Hm anyone got an idea how to keep `through` data? Do I actually NEED the `through` table or is it optional? |
# |
Jun 7th 2019, 04:45 |
conehead |
Guess it should be `Asia/Malaysia` |
# |
Jun 7th 2019, 04:44 |
liaogz82 |
or should it be `Asia/Malaysia`? |
# |
Jun 7th 2019, 04:43 |
liaogz82 |
can I set it as `GMT+8`?? |
# |
Jun 7th 2019, 04:38 |
niel45 |
defaults to UTC IIRC |
# |
Jun 7th 2019, 04:38 |
niel45 |
default timezone can be set in your app.php |
# |
Jun 7th 2019, 04:36 |
liaogz82 |
ok how do you set the timezone in cakephp? |
# |
Jun 7th 2019, 04:30 |
conehead |
And just make sure you get no errors with the timezone |
# |
Jun 7th 2019, 04:29 |
conehead |
And save it as DateTime |
# |
Jun 7th 2019, 04:29 |
conehead |
I am not an expert, but right now, in ```beforeMarshal()``` I would check if it is a valid timestamp and convert it to DateTime |
# |
Jun 7th 2019, 04:28 |
liaogz82 |
`"date_of_birth":1555862400000` |
# |
Jun 7th 2019, 04:28 |
liaogz82 |
well customer requirement is the data send over is in miliseconds |
# |
Jun 7th 2019, 04:27 |
conehead |
Or an int? |
# |
Jun 7th 2019, 04:27 |
conehead |
Why would you? As a string? |
# |
Jun 7th 2019, 04:27 |
liaogz82 |
check with you guys, how do you save date time in milliseconds in cakephp? |
# |
Jun 7th 2019, 04:21 |
liaogz82 |
oh god no! I go and add it in now |
# |
Jun 7th 2019, 04:17 |
conehead |
Did you add the `associated` key? ``` $entity = $articles->newEntity($this->request->getData(), [ 'associated' => [ 'Tags', 'Comments' => ['associated' => ['Users']] ] ]); ``` |
# |
Jun 7th 2019, 04:13 |
liaogz82 |
this part, should I change `worker_section_type` to `WorkerSectionType`?? |
# |
Jun 7th 2019, 04:12 |
slackebot |
"worker_overtime": [{ "code":"5S", "description":"AUDIT 5S", "amount":"1000", "remark":"PAJAK(5S)" }] } ``` |
# |
Jun 7th 2019, 04:12 |
liaogz82 |
``` "worker_section_type":{ "section_id":1, "worker_gaji": [{ "code":"PM_3U", "description":"MI 3 UDANG", "amount":"20", "remark":"PAJAK(1 BAG)" }], "worker_tambahan": [{ "code":"FULL_2U", "description":"F/HARIAN >100 BAGS 2 UDG", "amount":"10", "remark":"PAJAK(BAG)" }], |
# |
Jun 7th 2019, 04:11 |
liaogz82 |
but it does have many to many relationships |
# |
Jun 7th 2019, 04:11 |
liaogz82 |
no I just save one, not many |
# |
Jun 7th 2019, 04:10 |
conehead |
Guess you are looking for `saveMany()` https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-multiple-entities |
# |
Jun 7th 2019, 03:54 |
kgb.acct.personal |
https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-with-associations |
# |
Jun 7th 2019, 03:53 |
kgb.acct.personal |
Too bad. Looks like saveAll is not in Cake3 anymore. You can use just save() or saveMany() |
# |
Jun 7th 2019, 03:47 |
liaogz82 |
sorry I misinterpret what you say |
# |
Jun 7th 2019, 03:47 |
liaogz82 |
this is it |
# |
Jun 7th 2019, 03:47 |
liaogz82 |
``` public function add() { $worker = $this->Workers->newEntity(); $success = false; if ($this->request->is('post')) { $worker = $this->Workers->patchEntity($worker, $this->request->getData()); if ($this->Workers->saveAll($worker)) { $success = true; } $this->set([ 'success' => $success, '_serialize' => ['success'] ]); } } ``` |
# |
Jun 7th 2019, 03:39 |
kgb.acct.personal |
You're supposed to use your model table to call saveAll() |
# |
Jun 7th 2019, 03:38 |
kgb.acct.personal |
I mean the statement where you call saveAll() |
# |
Jun 7th 2019, 03:36 |
liaogz82 |
this is the data i want to save |
# |
Jun 7th 2019, 03:36 |
slackebot |
"phone_number":"019-8998571" } ``` |