individual attributes for each option (multi checkbox)#48
individual attributes for each option (multi checkbox)#48rodsouto wants to merge 3 commits intoauraphp:2.xfrom
Conversation
|
Sorry I understood it wrongly :) . Thanks for the PR. |
| $this->attribs['value'] = $value; | ||
| $this->attribs['label'] = $label; | ||
|
|
||
| $optionAttribs = isset($this->optionsAttribs[$value]) ? $this->optionsAttribs[$value] : []; |
There was a problem hiding this comment.
Travis broken due to 5.3 . Need to change short array to array.
|
Thanks @harikt 👍 |
| $this->attribs['value'] = $value; | ||
| $this->attribs['label'] = $label; | ||
|
|
||
| $optionAttribs = isset($this->options_attribs[$value]) ? $this->options_attribs[$value] : array(); |
|
Hey @jakejohns , Do you think we are good to merge this ? |
|
I like the concept. Here's some concerns off the top of my head: Update Docs
Should this apply to other helpers?I wonder if similar function should be applied to Spec StructureI actually think the way it's being done here is probably the right option, but I just thought I'd throw this out there to explicitly rule it out for a valid reason. I haven't messed with the I sort of wish the <?php
// calling
$actual = $checkbox(array(
'name' => 'foo',
'value' => 'yes',
'options' => array(
'yes' => array(
'label' => 'Yes',
'attr' => array('class' => 'test-class')
),
'no' => array(
'label' => 'No',
'attr' => array('data-no' => 1)
),
)
));
// Checkbox.php ... totally untested
protected function multiple()
{
$html = '';
$checkbox = clone($this);
$this->attribs['name'] .= '[]';
foreach ($this->options as $value => $label) {
$attr = array();
if (is_array($label)) {
$attr = $label['attr'];
$label = $label['label'];
}
$this->attribs['value'] = $value;
$this->attribs['label'] = $label;
$html .= $checkbox(array(
'name' => $this->attribs['name'],
'value' => $this->value,
'attribs' => $this->attribs + $attr
));
}
return $html;
} |
Hi guys, today I needed to set some data-attributes for a particular input in a multi checkbox, are you interested in this feature? :)