# |
Feb 13th 2020, 15:40 |
neon1024 |
I tend to do this if I need to change the odd field in a single form. If I need it elsewhere I make a templates file |
# |
Feb 13th 2020, 15:40 |
neon1024 |
You can use `$this->Form->setConfig('templates.checkbox', $myNewTemplate)` |
# |
Feb 13th 2020, 15:39 |
neon1024 |
I tend to replace this https://github.com/cakephp/cakephp/blob/3.5.18/src/View/Helper/FormHelper.php#L106 |
# |
Feb 13th 2020, 15:39 |
alexmax |
Cake 3.5 btw |
# |
Feb 13th 2020, 15:38 |
alexmax |
Without one, I get an error message saying it can't find a template for `checkboxContainer`. Should there be one? |
# |
Feb 13th 2020, 15:37 |
neon1024 |
@alexmax Are you giving a custom template string to the Form->setTemplate ? |
# |
Feb 13th 2020, 15:36 |
alexmax |
when you want "at least one of these checkboxes" |
# |
Feb 13th 2020, 15:35 |
alexmax |
Man I hope I don't have to resort to three separate fields again, validation and error rendering on those is a pain in the neck |
# |
Feb 13th 2020, 15:35 |
sebastian.krzewinski. |
i dont get.. do all with docs.. not work.. add 1 line and everything fine |
# |
Feb 13th 2020, 15:35 |
alexmax |
Hrm, even when I supply a basic template for `checkboxContainer` the resulting HTML is lacking - the checkboxes are missing labels. |
# |
Feb 13th 2020, 15:33 |
dereuromark |
true :) ignore deprecations |
# |
Feb 13th 2020, 15:32 |
spriz |
AuthComponent is also still working all good :v: |
# |
Feb 13th 2020, 15:31 |
dereuromark |
good old days where you used TinyAuth and 3 lines of config and all worked fine. |
# |
Feb 13th 2020, 15:30 |
sebastian.krzewinski. |
im done for today.. this docs not working (auth) |
# |
Feb 13th 2020, 15:27 |
spriz |
I like the first one better, and that was the one I have used the most but I've been confused since the 2nd was added :shrug: |
# |
Feb 13th 2020, 15:27 |
neon1024 |
Seriously @spriz No idea! :thinking_face: Probably the first option? It’s readable |
# |
Feb 13th 2020, 15:26 |
dereuromark |
darn, he was faster |
# |
Feb 13th 2020, 15:26 |
dereuromark |
actually, make it a separate class and inject it. |
# |
Feb 13th 2020, 15:26 |
neon1024 |
Injected via DI container |
# |
Feb 13th 2020, 15:26 |
neon1024 |
Wrap it in a private method too |
# |
Feb 13th 2020, 15:26 |
neon1024 |
So I pick option 2 |
# |
Feb 13th 2020, 15:25 |
neon1024 |
More code means you’re working harder, so you get paid more :pokerface: |
# |
Feb 13th 2020, 15:25 |
spriz |
Which one do you use - why? :) |
# |
Feb 13th 2020, 15:24 |
spriz |
``` $this->request = $this->request->withData('foo', 'bar'); |
# |
Feb 13th 2020, 14:42 |
damiano |
ok |
# |
Feb 13th 2020, 14:40 |
noel |
The way I've done that in the past is in AppController... there I check the path in `$_SERVER['REQUEST_URI']` and set a viewVar if it is the home page. |
# |
Feb 13th 2020, 14:38 |
damiano |
so i need to find a way to understanrd if it is the home page or not, or maybe i just set('home', 1) inside the index() action and stop |
# |
Feb 13th 2020, 14:38 |
damiano |
i must load different classes |
# |
Feb 13th 2020, 14:38 |
damiano |
@noel it is a view problem, if it is the home page the header is different |
# |
Feb 13th 2020, 14:37 |
noel |
er.. sorry that posted while I was still thinking about it. pls ignore. |
# |
Feb 13th 2020, 14:36 |
noel |
@damiano I think you're approaching this in the wrong way. The way I would do that is in the AppController and use it to layout |
# |
Feb 13th 2020, 14:35 |
alexmax |
So I've got a question. I don't use `'type' => 'select', 'multiple' => 'checkbox'` with the formHelper terribly often, and I'm getting an error message saying that there is no `checkboxContainer` template. Is this expected? Does CakePHP simply not come with a built-in `checkboxContainer` template? Is that even the correct template for it to grab? Or is this likely something in my app breaking things? |
# |
Feb 13th 2020, 14:35 |
damiano |
so basically two different header so i woukld like to check automatically what class i should use looking at the current route/page |
# |
Feb 13th 2020, 14:34 |
damiano |
because in the header of my template i have different classes |
# |
Feb 13th 2020, 14:34 |
damiano |
then i need a way to understand if the page the user is seeing is the home page or not |
# |
Feb 13th 2020, 14:34 |
damiano |
@noel inside a view i need to check if the current route is a specified named route for example i add _name => 'home' inside my routes.php |
# |
Feb 13th 2020, 14:33 |
noel |
@damiano I'm not sure I understand your question. What is "Current Page"? |
# |
Feb 13th 2020, 14:30 |
damiano |
(inside a view) |
# |
Feb 13th 2020, 14:29 |
rightscoreanalysis |
but I think I need to lock down some fields |
# |
Feb 13th 2020, 14:29 |
rightscoreanalysis |
as mentioned I have some model methods which check a user is the owner of an entity and isAllowed |
# |
Feb 13th 2020, 14:29 |
damiano |
hi guys how can i check if the current page is == named route? |