[BUG] Sage Switch does not output `value` property as expected
Closed this issue · 1 comments
Detailed description
When a Sage Switch instance includes the value
property, the rendered output is actually the id
, and not the value
. While this may have been intentional, the result is that any provided value
will always be overridden by the id
:
This occurs for both the default Sage Switch and its standalone
variant, and can be seen on the documentation site. While each example has a unique value
, (ex. sage-switch-1
and sage-switch-1-value
), the rendered output only displays the id
.
Steps to reproduce
Describe the steps to reproduce the behavior:
- View the Sage Switch documentation
- Click the "Code" tab, and expand the "Sage Component" markup
- Verify that the
id
andvalue
of one of the examples uses separate strings - Scroll down and expand the "Generated HTML Code" markup
- Locate your example from step 3, and confirm that the
value
matches theid
output
Something to investigate further is the mismatch of Sage Switch with the Simpleform version. By design, checkboxes will not submit a value in forms when "unchecked". But because most of the Simpleform implementations must toggle a value in the database, they include a separate type="hidden"
input that submits an "off" value on behalf of the checkbox. This is only true for "traditional" forms and not Ajax requests. As a stopgap measure, most of these implementations have modified the Simpleform switch with Sage classes, or used custom markup to reconstruct the Sage Switch with an embedded hidden input.
There's at least a few possibilities to account for this difference:
- Add the option to append a
type="hidden"
input in Sage Switch - Modify the sage form helper or create a
kajabi-products
specific shared partial