Hi!
It’s me again, running into a small problem about how to elegantly solve one of my issues.
The situations is this: I have a products
table with a many-to-many relationship to a features
table. In the UI, I am rendering a checkbox for every row in features
for the user to select, and if it is ticked, that relationship is created. Now, the list of features is of course dynamic based on how many rows there are.
The code I am using for this right now is (using Surface):
<Form.Field :for={{ feature <- @features }} name={{ String.to_atom("#{feature.id}") }}>
<Form.Checkbox />
<Form.Label>{{ gettext "label" }}</Form.Label>
</Form.Field>
Now, this works. My question is about using String.to_atom/1
and DoSing myself. Using just :checkbox
as the name obviously does not work as it would create multiple fields with the same name, giving me only one parameter.
Is there any way to do this without creating a possibly infinite amount of atoms? The name
field does not take strings, so I am unsure how to proceed.
Thanks!