# |
Jul 15th 2019, 18:49 |
daniel.upshaw |
Or that perhaps |
# |
Jul 15th 2019, 18:49 |
daniel.upshaw |
```<?php // Using a classname. $this->Form->addWidget( 'ToggleInput', ['widgets' => ['Theme.ToggleInput', 'checkbox', 'nestingLabel']] );``` |
# |
Jul 15th 2019, 18:49 |
ricksaccous |
i'll try that later though |
# |
Jul 15th 2019, 18:49 |
ricksaccous |
I think if anything would work it would be this |
# |
Jul 15th 2019, 18:49 |
daniel.upshaw |
Hmmm |
# |
Jul 15th 2019, 18:48 |
slackebot |
<ricksaccous> |
# |
Jul 15th 2019, 18:48 |
daniel.upshaw |
(Just guessing here) |
# |
Jul 15th 2019, 18:47 |
daniel.upshaw |
```[ 'widgets' => [ 'toggleInput' => ['Theme\View\Widget\ToggleInput', 'nestingLabel'] ] ]``` |
# |
Jul 15th 2019, 18:47 |
daniel.upshaw |
It might not be exactly that though |
# |
Jul 15th 2019, 18:46 |
daniel.upshaw |
@ricksaccous I wonder if that would modify `$_defaultWidgets` |
# |
Jul 15th 2019, 18:46 |
daniel.upshaw |
```[ 'widgets' => [ 'toggleInput' => ['nestingLabel'] ] ]``` |
# |
Jul 15th 2019, 18:45 |
daniel.upshaw |
https://book.cakephp.org/3.0/en/views/helpers/form.html#using-widgets |
# |
Jul 15th 2019, 18:45 |
ricksaccous |
anyway an element is not a bad solution imo |
# |
Jul 15th 2019, 18:44 |
ricksaccous |
yeah I'm not going to mess with formHelper just to get what i want out of this widget, lol |
# |
Jul 15th 2019, 18:43 |
daniel.upshaw |
I think that `$_defaultWidgets` looks promising |
# |
Jul 15th 2019, 18:43 |
daniel.upshaw |
But this is your custom |
# |
Jul 15th 2019, 18:43 |
daniel.upshaw |
Ah |
# |
Jul 15th 2019, 18:43 |
daniel.upshaw |
`By default CakePHP nests checkboxes created via control() and radio buttons created by both control() and radio() within label elements.` |
# |
Jul 15th 2019, 18:42 |
daniel.upshaw |
https://book.cakephp.org/3.0/en/views/helpers/form.html#moving-checkboxes-radios-outside-of-a-label |
# |
Jul 15th 2019, 18:42 |
daniel.upshaw |
For `control()` |
# |
Jul 15th 2019, 18:42 |
daniel.upshaw |
By default it's supposed to use `nestingLabel` |
# |
Jul 15th 2019, 18:41 |
daniel.upshaw |
I wonder if that controls what uses nestingLabel |
# |
Jul 15th 2019, 18:40 |
ricksaccous |
yes |
# |
Jul 15th 2019, 18:40 |
daniel.upshaw |
That's in `Cake\View\FormHelper` |
# |
Jul 15th 2019, 18:40 |
slackebot |
['Textarea'], 'datetime' => ['DateTime', 'select'], '_default' => ['Basic'], ];``` |
# |
Jul 15th 2019, 18:40 |
daniel.upshaw |
``` /** * Default widgets * * @var array */ protected $_defaultWidgets = [ 'button' => ['Button'], 'checkbox' => ['Checkbox'], 'file' => ['File'], 'label' => ['Label'], 'nestingLabel' => ['NestingLabel'], 'multicheckbox' => ['MultiCheckbox', 'nestingLabel'], 'radio' => ['Radio', 'nestingLabel'], 'select' => ['SelectBox'], 'textarea' => |
# |
Jul 15th 2019, 18:40 |
ricksaccous |
and for regular checkboxes not using my widget it uses nestingLabel |
# |
Jul 15th 2019, 18:40 |
ricksaccous |
there's magic in formhelper that decides which label widget/template it uses |
# |
Jul 15th 2019, 18:40 |
daniel.upshaw |
Hrm |
# |
Jul 15th 2019, 18:39 |
daniel.upshaw |
Oh |
# |
Jul 15th 2019, 18:39 |
ricksaccous |
and i don't know how to specify that |
# |
Jul 15th 2019, 18:39 |
daniel.upshaw |
Why not keep everything "toggleWidget" |
# |
Jul 15th 2019, 18:39 |
ricksaccous |
but i want the control to use nestingLabel |
# |
Jul 15th 2019, 18:39 |
ricksaccous |
it uses 'label' |
# |
Jul 15th 2019, 18:39 |
daniel.upshaw |
Hmmm |
# |
Jul 15th 2019, 18:39 |
ricksaccous |
except the stupid label |
# |
Jul 15th 2019, 18:39 |
daniel.upshaw |
``` $templates->add( [ 'inputContainer' => $templates->get('toggleWidget'), 'checkbox' => $templates->get('toggleWidgetCheckbox'), 'nestingLabel' => $templates->get('nestingLabelToggleWidget') ] );``` |
# |
Jul 15th 2019, 18:39 |
ricksaccous |
and they are being used |
# |
Jul 15th 2019, 18:39 |
ricksaccous |
yes, with the templates predefined |
# |
Jul 15th 2019, 18:38 |
daniel.upshaw |
Nice |
# |
Jul 15th 2019, 18:38 |
daniel.upshaw |
Oooh I see you're making a custom type |