Ticket #114 (closed enhancement: fixed)

Opened 1 year ago

Last modified 1 year ago

[PATCH] control_for :boolean (checkbox)

Reported by: mattaimonet..@gmail.com Assigned to: somebody
Priority: medium Milestone: 0.4.2
Component: Views Keywords: control_for, checkbox, view,
Cc:

Description

Attached is a patch (with tests) to add a checkbox field to your form. Here is an usage example:

<%= control_for @invoice, :paid, :boolean, :label => 'Already paid?' %>

generates:

<label for="invoice_paid">Already paid?</label>
<input type="checkbox" id="invoice_paid" name="invoice[paid]" value="true"/>

Note that the return value is 'true' and not 'on' as a default html checkbox form would return.

Attachments

added_control_for_boolean.diff (3.8 kB) - added by mattaimonet..@gmail.com on 08/05/07 20:13:23.

Change History

08/05/07 20:13:23 changed by mattaimonet..@gmail.com

  • attachment added_control_for_boolean.diff added.

08/05/07 22:45:55 changed by has.s..@gmail.com

I think this needs to automatically check the box if the corresponding model method evaluates to true. This would bring it in line with other control_for code.

(follow-up: ↓ 6 ) 08/05/07 23:24:13 changed by jon.egil.stra..@gmail.com

mattaimonetti, thank you for the patch.

has.sox: agreed also, to align with the other control_for, type should be :checkbox, not :boolean.

08/06/07 00:52:35 changed by has.s..@gmail.com

Yes checkbox should be there. I quite like the :boolean type though. It's only for true/false, where checkbox could be for an arbitrary value. Saves typing for me.

What if there where a general purpose :checkbox, with :checked_value & :unchecked_value

:boolean could then just use that.

What do you think?

08/07/07 00:43:27 changed by jon.egil.stra..@gmail.com

  • milestone changed from 0.3.x to 0.4.

I bump this to 0.4. Should be integrated with #108.

08/09/07 01:05:41 changed by jon.egil.stra..@gmail.com

  • milestone changed from 0.4 to The Future.

(in reply to: ↑ 2 ) 08/12/07 00:06:36 changed by mattaimonet..@gmail.com

Replying to jon.egil.stra..@gmail.com:

has.sox: agreed also, to align with the other control_for, type should be :checkbox, not :boolean.

Not really, I think that you explained later there is a difference between a checkbox and a boolean. A boolean would just be true/false while a checkbox can have different values.

Since form_controller_mixin has been renamed I'll have to redo the patch anyway. Don't you think that it's important enough to make it to 0.4 instead of an unknown future release?

08/12/07 04:07:07 changed by jon.egil.stra..@gmail.com

No problem doing it now, it's more the fact that at present we are at a standstill waiting for the plugin architecture in 0.4, and I guess we'll make a 0.4.1 where stuff like this comes in.

08/12/07 09:45:20 changed by mattaimonet..@gmail.com

sounds good to me. Thanks

10/30/07 22:30:18 changed by iv..@gweezlebur.com

BUMP

11/13/07 10:08:35 changed by iv..@gweezlebur.com

  • milestone changed from The Future to 0.4.2.

11/24/07 14:16:12 changed by e.@brainspl.at

Whats up with this patch now? I think we are going to be ditching the formcontrolmixin in favor of having people use the merb_helpers plugin.

Can anyone else comment?

11/25/07 11:25:59 changed by mattaimonet..@gmail.com

the merb_helpers plugin already got these features. I agree that we should ditch the formcontrolmixin.

12/13/07 22:57:35 changed by e.@brainspl.at

  • status changed from new to closed.
  • resolution set to fixed.

Form control mixin is deprecated. Closing thisticket