-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
individual attributes for each option (multi checkbox) #48
base: 2.x
Are you sure you want to change the base?
Conversation
Sorry I understood it wrongly :) . Thanks for the PR. |
src/Helper/Input/Checkbox.php
Outdated
@@ -80,10 +107,12 @@ protected function multiple() | |||
$this->attribs['value'] = $value; | |||
$this->attribs['label'] = $label; | |||
|
|||
$optionAttribs = isset($this->optionsAttribs[$value]) ? $this->optionsAttribs[$value] : []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Travis broken due to 5.3 . Need to change short array to array.
Thanks @harikt 👍 |
src/Helper/Input/Checkbox.php
Outdated
@@ -80,10 +107,12 @@ protected function multiple() | |||
$this->attribs['value'] = $value; | |||
$this->attribs['label'] = $label; | |||
|
|||
$optionAttribs = isset($this->options_attribs[$value]) ? $this->options_attribs[$value] : array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably here also :) .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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? :)