Skip to content
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

Is there a way to wrap labels of checkbox options? #151

Open
kyzn opened this issue Dec 3, 2018 · 0 comments
Open

Is there a way to wrap labels of checkbox options? #151

kyzn opened this issue Dec 3, 2018 · 0 comments

Comments

@kyzn
Copy link

kyzn commented Dec 3, 2018

Hi! Thanks for maintaining HTML::FormHandler. Just had a question about CheckboxGroup & rendering.

Following this documentation, following example works fine: It wraps outer label of checkbox group.

has_field 'my_select' => (
  type     => 'Select',
  label    => 'This is a label',
  widget   => 'CheckboxGroup',
  options  => [
    {value => 'x', label => 'labelx',},
    {value => 'y', label => 'labely',}
  ],
  wrap_label_method => \&wrap_label, # <--- WRAPPING HERE
);

sub wrap_label {
  my ( $self, $label ) = @_;
  return qq{<a href="...">$label</a>};
}

However, I could not get the same to work for labels for each option inside the checkbox. So, for example, this doesn't wrap labels of options.

has_field 'my_select' => (
  type     => 'Select',
  label    => 'This is a label',
  widget   => 'CheckboxGroup',
  options  => [
    {value => 'x', label => 'labelx', wrap_label_method => \&wrap_label, },  # <--- WRAPPING HERE
    {value => 'y', label => 'labely', wrap_label_method => \&wrap_label, },  # <--- WRAPPING HERE
  ],
);

sub wrap_label {
  my ( $self, $label ) = @_;
  return qq{<a href="...">$label</a>};
}

I was wondering if there's an existing way to achieve this. If not, would you be interested in a PR that introduces this functionality?

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant