The way the current form->radio method works, it puts the “checked” attribute on the input box, but, a label is drawn for each of the entries within the radio option.
When it draws the label, it does not have any way to know that the label for a specific entry is the selected entry.
This was very easy to overcome by going into the logic where the option “checked” is defined and adding a [‘templateVars’] option for the label. In my case, I used $radio[‘templateVars’][‘activeClass’] = “active”.
fyi, my solution is in my _renderInput method of RadioWidget
It was a hard learning curve to figure it all out, but, once I did, it was one line of code. Sweet.
I really don’t feel comfortable modifying code in the “vendor” directory, the moment I do that there is going to be an upgrade and I lose my changes, then the code stops working. Bad.
I’ve made a copy of my RadioWidget in a plugin,
class RadioWidget extends \BootstrapUI\View\Widget\RadioWidget implements WidgetInterface
I’ve already got FormHelper in my plugin
class FormHelper extends \BootstrapUI\View\Helper\FormHelper{
protected $_widgets =
I’m running into issues of my class is already loaded.
Cannot declare class Dwilbanks\View\Widget\RadioWidget because the name is already in use in D:\wamp\www\tssc\plugins\Dwilbanks\src\View\Widget\RadioWidget.php
My question is, what is the proper way to do what I’m attempting. The core functionality of the cakephp RadioWidget is very close to what I need, but, slightly different. I need one line, but, I don’t want to modify the vendor code. I want to overwrite the specific class in my own code space.
Thoughts?