loadsys / loadsys/twitter-bootstrap-helper
There is a strict error in the Form helper / radio method in PHP 5.4.x
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 168
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
## Error Message:
Strict (2048): Declaration of BootstrapFormHelper::radio() should be compatible with FormHelper::radio($fieldName, $options = Array, $attributes = Array) [ROOT/plugins/TwitterBootstrap/View/Helper/BootstrapFormHelper.php, line 456]
## Solution:
``` php
/**
* Outputs a list of radio form elements with the proper
* markup for twitter bootstrap styles
*
* @param array $options
* @param array $attr
* @access public
* @return string
*/
public function radio($field, $options = array(), $attr = array()) {
if (is_array($field)) {
$options = $field;
} else {
$options["field"] = $field;
}
if (!isset($options["options"]) || !isset($options["field"])) {
return "";
}
$opt = $options["options"];
unset($options["options"]);
$inputs = "";
$attr['label'] = false;
$attr['hiddenField'] = (isset($options['hiddenField']) && $options['hiddenField']);
foreach ($opt as $key => $val) {
$input = parent::radio(
$options["field"],
array($key => $val),
$attr
);
$id = array();
preg_match_all("/id=\"[a-zA-Z0-9_-]*\"/", $input, $id);
if (!empty($id[0])) {
$id = end($id[0]);
$id = substr($id, 4);
$id = substr($id, 0, -1);
$input = $this->Html->tag(
"label",
$input,
array("class" => "radio", "for" => $id)
);
}
$inputs .= $input;
}
$options["input"] = $inputs;
return $this->input($options);
}
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in plugins/TwitterBootstrap/View/Helper/BootstrapFormHelper.php around line 456 and compare BootstrapFormHelper::radio() with FormHelper::radio($fieldName, $options, $attributes). Verify the helper's radio output still uses the Bootstrap markup shown in the issue and that the PHP 5.4 strict compatibility error is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100