Closed John-vd-Berg closed 11 months ago
Greetings,
After updating to petal 1.7 we noticed an error when using a form_field of type switch and passing a class attribute.
Heres the error message: cannot convert the given list to a string.
To be converted to a string, a list must either be empty or only contain the following elements:
Please check the given list or call inspect/1 to get the list representation, got:
["", nil]
The error occurs here: petal_components/lib/petal_components/form.ex:611
petal_components/lib/petal_components/form.ex:611
This happens due to the string interpolation used for the switch.
This works: <.form_field type="switch" form={f} field={:my_field} classes={if @read_only?, do: "cursor-not-allowed"} />
This breaks: <.form_field type="switch" form={f} field={:my_field} class={if @read_only?, do: "cursor-not-allowed"} />
Amendment: this seems to happen only when using if without an else
Thanks will take a look
Should be fixed in 1.7.1
Greetings,
After updating to petal 1.7 we noticed an error when using a form_field of type switch and passing a class attribute.
Heres the error message: cannot convert the given list to a string.
To be converted to a string, a list must either be empty or only contain the following elements:
Please check the given list or call inspect/1 to get the list representation, got:
["", nil]
The error occurs here:
petal_components/lib/petal_components/form.ex:611
This happens due to the string interpolation used for the switch.
This works: <.form_field type="switch" form={f} field={:my_field} classes={if @read_only?, do: "cursor-not-allowed"} />
This breaks: <.form_field type="switch" form={f} field={:my_field} class={if @read_only?, do: "cursor-not-allowed"} />