# |
Sep 23rd 2019, 06:37 |
jotpe |
I have a custom app_form.php with custom templates |
# |
Sep 23rd 2019, 06:37 |
jotpe |
But how do I need so check if a field is required? |
# |
Sep 23rd 2019, 06:36 |
conehead |
https://api.cakephp.org/3.8/class-Cake.View.Helper.FormHelper.html#%24_defaultConfig |
# |
Sep 23rd 2019, 06:36 |
conehead |
https://book.cakephp.org/3.0/en/views/helpers/form.html#customizing-the-templates-formhelper-uses |
# |
Sep 23rd 2019, 06:35 |
conehead |
@jotpe create a default template and set it in appview |
# |
Sep 23rd 2019, 06:25 |
jotpe |
How can I change the templates of FormHelper so that the Labels of required Controls get a hint htat it's required? E.g. `<label>E-Mail <strong>*</strong></label>` |
# |
Sep 23rd 2019, 06:18 |
jotpe |
@valerij.bancer I had the same issue when migrating from 2.x to 3.x and ended up doing something like this https://www.dereuromark.de/2010/06/24/static-enums-or-semihardcoded-attributes/ but in Entities with a trait. |
# |
Sep 23rd 2019, 06:15 |
jotpe |
Morning |
# |
Sep 23rd 2019, 05:17 |
javier.villanueva |
morning all |
# |
Sep 23rd 2019, 04:40 |
conehead |
Good morning guys |
# |
Sep 22nd 2019, 20:55 |
admad |
nucc11: https://github.com/cakephp/app/blob/master/config/bootstrap.php#L47 |
# |
Sep 22nd 2019, 19:20 |
nucc11 |
it appears that the development server doesn't automatically load the contents of .env file, or am i missing something? |
# |
Sep 22nd 2019, 18:16 |
c.wichmann |
Ä |
# |
Sep 22nd 2019, 16:43 |
valerij.bancer |
I wish we would not use cake 2.x at all |
# |
Sep 22nd 2019, 16:38 |
admad |
no one's forcing you to use CakePHP or if someone is take it up with them :slightly_smiling_face: |
# |
Sep 22nd 2019, 16:34 |
valerij.bancer |
what should projects with enum data types do? migrate to another framework? |
# |
Sep 22nd 2019, 16:31 |
admad |
"no and probably never will be" |
# |
Sep 22nd 2019, 16:25 |
valerij.bancer |
I mean MySQL data type `enum`. cakedc/enum seems to be something different |
# |
Sep 22nd 2019, 16:23 |
admad |
no and probably never will be. There are plugin's to emulate enums though, like cakedc/enum |
# |
Sep 22nd 2019, 16:21 |
valerij.bancer |
is there any support of enum data type in 3.x? |
# |
Sep 22nd 2019, 15:21 |
nucc1 |
doesn't look like there's a way to allow-all, so go ahead without the Authentication component. |
# |
Sep 22nd 2019, 15:06 |
admad |
the 2 components are not dependent on each other |
# |
Sep 22nd 2019, 15:03 |
nucc1 |
I like the convenience as well, but i want to do the decision making about what to do myself |
# |
Sep 22nd 2019, 15:03 |
nucc1 |
I am hoping to use the Authorization comonent as well and assumed they go together |
# |
Sep 22nd 2019, 15:02 |
admad |
the component just provides some extra convenience, it's not really necessary for the auth process |
# |
Sep 22nd 2019, 15:02 |
admad |
*that's one way |
# |
Sep 22nd 2019, 15:02 |
admad |
they one way. Another thing is for what else do you need the component? |
# |
Sep 22nd 2019, 14:58 |
nucc1 |
did you mean make it default to allow-all and then just read the results and do what I desire? I can't see how too use it without loading it |
# |
Sep 22nd 2019, 14:52 |
nucc1 |
thanks. :) |
# |
Sep 22nd 2019, 13:30 |
admad |
*AuthenticationComponent |
# |
Sep 22nd 2019, 13:30 |
admad |
nucc1: just dont load the AuthComponent? Then you can just check result and do whatever you want |
# |
Sep 22nd 2019, 12:59 |
nucc1 |
when using the Authentication plugin, is it possible to catch and do something else with the UnAuthenticatedException, or do I have to rely on the redirect? |
# |
Sep 22nd 2019, 12:42 |
noel |
There are but they don't seem to work for json-api. Thx anyhow. |
# |
Sep 22nd 2019, 12:27 |
adam282 |
I am sure there is some built-in Cake routines and response handlers for JSON |
# |
Sep 22nd 2019, 12:26 |
adam282 |
Honestly, I have no idea as in the last app I wrote, I had a small subset of functions that required a JSON response and that was CakePHP 2.x so I did it the way you just mentioned. |
# |
Sep 22nd 2019, 12:22 |
noel |
@adam282 turning off autorender and setting the layout to false does indeed prevent the template from being required, which is cool. However _serialize doesn't result in any output. Is there a way to interact with crud-json-api's classes so as to build up a json-api response? Obviously I build up an array manually and then json_encode it and send it as a response but that seems like re-inventing the wheel. |
# |
Sep 22nd 2019, 12:18 |
noel |
Ok tx I'll try that. I found this works although it seems heavy-handed: ``` public function index() { if ($this->request->is('jsonapi')) { $response = new \Cake\Http\Response; $response = $response->withType('application/json') ->withStringBody(json_encode(['success' => true])); } return $response; } ``` |
# |
Sep 22nd 2019, 12:13 |
adam282 |
Something like this inside your function inside your Controller: ``` $this->viewBuilder()->setLayout(false); $this->autoRender = false; ``` |
# |
Sep 22nd 2019, 12:12 |
adam282 |
Yeah, you need to turn off autorender and set the layout to false |
# |
Sep 22nd 2019, 12:09 |
noel |
Hi. Working with crud-json-api – is there a way to have a custom response that has nothing to do with table's in the database for a particular Controller? I tried doing `$this->loadComponent('RequestHandler')` and `$this->set('_serialize', ['myVar'])` but it still seems to be asking for the template. |
# |
Sep 22nd 2019, 11:19 |
admad |
@val https://github.com/FriendsOfCake/fixturize |