Add slot support to form builder radio and checkbox components
I have noticed when migrating checkboxes to use gitlab_ui_checkbox_component
sometimes the checkbox requires HTML in the label or help text. With the current implementation you have to use sprintf
to create a string and then pass it to the label
or help_text
argument.
We can utilize ViewComponent slots to make using HTML in the label or help text easier and cleaner.
Before
- label = _('Allow projects within this group to use Git LFS')
- help_link = link_to sprite_icon('question-o'), help_page_path('topics/git/lfs/index'), class: 'gl-ml-2'
= f.gitlab_ui_checkbox_component :lfs_enabled,
'%{label}%{help_link}'.html_safe % { label: label, help_link: help_link },
help_text: _('This setting can be overridden in each project.'),
checkbox_options: { checked: @group.lfs_enabled? }
After
= f.gitlab_ui_checkbox_component :lfs_enabled, checkbox_options: { checked: @group.lfs_enabled? } do |c|
= c.label do
= _('Allow projects within this group to use Git LFS')
= link_to sprite_icon('question-o'), help_page_path('topics/git/lfs/index'), class: 'gl-ml-2'
= c.help_text do
= _('This setting can be overridden in each project.')