# |
Dec 4th 2019, 13:05 |
graziel |
then 'setTemplatePath' is relative to it |
# |
Dec 4th 2019, 13:05 |
graziel |
iirc in app.php you have setting to templates in general |
# |
Dec 4th 2019, 13:04 |
noel |
Cool.. what would go in the path though? I tried all the combinations I could think of. E.g. `'\App\Templates\Enquiries\index.ctp'`, `'\Templates\Enquiries\index.ctp'` , `'\App\Templates\Enquiries'` , , `'\Templates\Enquiries'` , `'\App\Templates\Enquiries\index'`, `'\Templates\Enquiries\index'` .... none of those works. |
# |
Dec 4th 2019, 12:58 |
graziel |
maybe ```$this->viewBuilder() ->setTemplatePath('path');``` |
# |
Dec 4th 2019, 12:58 |
info315 |
You can pass a path like so: `$this->render('/Errors/error403');` maybe this helps |
# |
Dec 4th 2019, 12:57 |
noel |
I tried using `$this->render()` but it seems always to default to the subfolder. |
# |
Dec 4th 2019, 12:56 |
noel |
Let's say I have a controller in a subfolder: `\App\Controller\Customer\MyController.php` which is an extension of a controller in the main folder `\App\Controller\MyController.php`. Is there a way I can point the extension to the Template of it's parent controller, rather than having to create folders and duplicate Template files? |
# |
Dec 4th 2019, 12:24 |
neon1024 |
Looks like some people posted solutions in the comments to get it without a namespace though |
# |
Dec 4th 2019, 12:23 |
neon1024 |
Ah, it returns the namespace! |
# |
Dec 4th 2019, 12:23 |
neon1024 |
Isn’t that get_class? https://www.php.net/manual/en/function.get-class.php |
# |
Dec 4th 2019, 12:22 |
admad |
App::shortName() |
# |
Dec 4th 2019, 12:17 |
val |
Hi, is there a function in 3.x that gets the class name of an object stripping a namespace? |
# |
Dec 4th 2019, 11:28 |
info315 |
Thanks @ndm, this seems to work: ``` $this->set('error', $command->getErrors()); $this->viewBuilder()->setOption('serialize', ['error']); $this->response = $this->response->withStatus(400); return;``` |
# |
Dec 4th 2019, 11:27 |
ndm |
And as mentioned the status can then be set by reassigning the response, like `$this->response = $this->response->withStatus(400);` |
# |
Dec 4th 2019, 11:25 |
ndm |
Do you really want to stop the controller, or just your controller action logic? In the latter case you can return `null`, this will halt your action logic, but the controller logic will continue and render your view. |
# |
Dec 4th 2019, 11:23 |
info315 |
this was the only way i found, to get something else than 200 Ok |
# |
Dec 4th 2019, 11:22 |
info315 |
but i don't know how to change the statuscode |
# |
Dec 4th 2019, 11:22 |
info315 |
I just want to set the statuscode to 400 and stop controller execution |
# |
Dec 4th 2019, 11:22 |
ndm |
Returning a response object from a controller will circumvent the rendering process. You probably just want to reassign the response property. |
# |
Dec 4th 2019, 11:19 |
slackebot2 |
$this->response->withStatus(400);``` |
# |
Dec 4th 2019, 11:19 |
info315 |
I still have issues while i try to set a HTTP status code with cake4 rc2 and respons json output. I try it like this and my status code is 400, but i don't get any response data at all: ``` $CommandsTable->save($command); if ($command->hasErrors()) { $this->set('error', $command->getErrors()); $this->viewBuilder()->setOption('serialize', ['error']); return |
# |
Dec 4th 2019, 10:48 |
latenal |
Thanks! |
# |
Dec 4th 2019, 10:28 |
admad |
https://book.cakephp.org/3/en/core-libraries/form.html |
# |
Dec 4th 2019, 10:28 |
admad |
@latenal use the Form class and set validations for it |
# |
Dec 4th 2019, 10:27 |
admad |
You don't need an external lib for something that already exists in core |
# |
Dec 4th 2019, 10:25 |
admad |
https://github.com/cakephp/validation |
# |
Dec 4th 2019, 10:24 |
slackebot2 |
!awesome |
# |
Dec 4th 2019, 10:24 |
slackebot2 |
Command sent from Slack by challgren: |
# |
Dec 4th 2019, 10:24 |
slackebot2 |
! awesome |
# |
Dec 4th 2019, 10:24 |
slackebot2 |
Command sent from Slack by challgren: |
# |
Dec 4th 2019, 10:16 |
latenal |
Hi! Is there a plugin for upload validation without saving it to the database? |
# |
Dec 4th 2019, 10:07 |
javier.villanueva |
sure |
# |
Dec 4th 2019, 10:07 |
challgren |
The 2 cat bullied the dog |
# |
Dec 4th 2019, 10:07 |
javier.villanueva |
haha |
# |
Dec 4th 2019, 10:07 |
challgren |
2 cats vs 1 dog different story! |
# |
Dec 4th 2019, 10:07 |
javier.villanueva |
don't forget to always have food on the plate |
# |
Dec 4th 2019, 10:06 |
challgren |
The dog learned cat habits and the cat learned dog habits! |
# |
Dec 4th 2019, 10:06 |
javier.villanueva |
always there are exceptions xD |
# |
Dec 4th 2019, 10:06 |
challgren |
@javier.villanueva nah! My cat and dog got along well! |
# |
Dec 4th 2019, 10:06 |
javier.villanueva |
another tip, you should never mix dogs and cats |
# |
Dec 4th 2019, 10:01 |
neon1024 |
My guess is yesterday you were on convention, and has DogsCatsTable and DogsCatsController. I would guess that something has changed with the naming or aliases |