lundi 23 juillet 2018

rails : Get/Set checkbox value in HTML5 fields dynamically from model

I have a Text field which contains HTML5 set by an HTML5 editor (CKEditor). Inside this text field and with the editor, I position and name some checkboxes like

<div style="margin-left: 40px;"><input type="checkbox" name="CODE1" value="CODE1Value"> Contact authorized.</div>

<div style="margin-left: 40px;"><input type="checkbox" name="CODE2" value="CODE2Value"> Send email authorized </div>

which appear through a <%= raw(@s)%> in my view

Now, my question and my challenge is how I could databind (set/get) the checkboxes values (checked or unchecked) from/to a model in rails (eg: ["CODE1", false] ["CODE2, true]).

Thanks for any help or advice.




Aucun commentaire:

Enregistrer un commentaire