samedi 21 février 2015

passing extra data along with checked checkbox

I have these checkboxes:



<div id="part-status-checkboxes" class="span5 ">
<div><strong>Complete</strong></div>
<div class="form-input-wrapper inline-radio-buttons">
<span class="button-label">
Setup Ready
</span>
<span>
<input id="setup_ready" name="status[setup_ready]" type="hidden" value="">
<input id="status_setup_ready" name="status[setup_ready]" type="checkbox" value="setup_ready">
</span>
</div>
<div class="form-input-wrapper inline-radio-buttons">
<span class="button-label">
Setup Required
</span>
<span>
<input id="setup_required" name="status[setup_required]" type="hidden" value="">
<input disabled="disabled" id="status_setup_required" name="status[setup_required]" type="checkbox" value="setup_required">
</span>
</div>
<div class="form-input-wrapper inline-radio-buttons">
<span class="button-label">
BOM - Processing
</span>
<span>
<input id="bom_processing" name="status[bom_processing]" type="hidden" value="">
<input disabled="disabled" id="status_bom_processing" name="status[bom_processing]" type="checkbox" value="bom_processing">
</span>
</div>
<div class="form-input-wrapper inline-radio-buttons">
<span class="button-label">
Pending Approval
</span>
<span>
<input id="pending_approval" name="status[pending_approval]" type="hidden" value="">
<input disabled="disabled" id="status_pending_approval" name="status[pending_approval]" type="checkbox" value="pending_approval">
</span>
</div>
<div class="form-input-wrapper inline-radio-buttons">
<span class="button-label">
Part Ready
</span>
<span>
<input id="part_live" name="status[part_live]" type="hidden" value="">
<input disabled="disabled" id="status_part_live" name="status[part_live]" type="checkbox" value="part_live">
</span>
</div>
</div>


I am passing to controller via the hidden fields the value of the checkbox because I need a false value if the check box isn't checked.


I also want to be able to pass to the controller whether the checkbox has been checked so that in the data base I can leave the original value. Hope that makes sense. The reason I am not letting rails do its thing with these check boxes is because they associate two different tables. I would prefer to not add another hidden field and I can't seem to pass a hash as the hidden fields value.





Aucun commentaire:

Enregistrer un commentaire