Validates_presence_of on alternative fields


I am trying to validate presence of one of two form fields.
I want to check if there is only one from two possible checkbox
I tried to find any hints in documentation, but as a beginner I wasn't
able to invent solution.

Best regards!

Why don’t you use a radiobox?


Validation is not on form fields but on data about to be saved to the
database. Do you have two columns in the table, one for each
checkbox? If so, and only one of them should be selected then reduce
it to a single column. As far as the form is concerned you may be
better with a radio box as Amador has suggested. If you need them to
be checkboxes you could use javascript to clear one when the other is


Well I am using Hobo, which in my case generates form with boolean
fields as checkbox.
Form is rendered from following dryml:
<def tag="win-form" for="Lead">
  <form lifecycle="win" merge param="default">
    <error-messages param/>
    <input type="hidden" name="key"
value="&this.lifecycle.provided_key" if="&this.lifecycle.provided_key"/

    <field-list fields="proposal, duration, value, contract_signed,
start_at_risk" param/>
    <div param="actions">
      <submit label="#{ht '', :default=>['Win']}"
param/><or-cancel param="cancel"/>
Validation I want to use would be placed in Lead model for specified
transition, but if we could do it other way it would be fine too.

To be honest I am not sure how to put javascript inside it (but its
true it would be much easier with js) nor how to switch to radioboxes.
If you know what should I do please give me a hint.

I'll ask similar question on Hobo group.

Best regards,