[Nitro] [PATCH] Controls patch + bugfix

Jonas Pfenniger zimba.tm at gmail.com
Mon Jan 9 03:46:50 EST 2006

Bryan Soto wrote:

> Hi Jonas,

Hi Bryan

> I like the password control, it's very cool. And you beat me to that
> Nitro::RenderExit that was bugging me ;)

Thanks. George always import Nitro so he didn't encounter this problem :-p

> As a note for George, both this and Chris' patch implement the
> plus/minus button for fixnums, so if you use both, you'll have
> conflicts. Only difference I noticed was, when the fixnum field
> contained "TEST":
> Chris' patch:
> would consider this as 0, and increment or decrement.
> Jonas' patch:
> is stricter and converts this to nan (Not a number).
> Other than that, everything seems to work as advertised. :)

I think Chris' patch is better because a number is always expected. Or
it should return NULL if Nan ?

> Jonas, I wonder if I understand controls correctly. You specify
> controls for properties, via annotations or directly in the model,
> than you can use form_for to have Nitro just create the form for you
> rather than coding everything out in the view? Is that right?

I always used that feature with part/admin so I can't tell exactly. But
it uses the form rendering so it should work like you said.

Every control extends the Control class and implements the render
method. There are also other facilities like js and css methods. The
Control.map setting defines a hash with the various controls.

When building your model, you can override the default control for a
specific property by using :control => :control_name.

As an example :

class User
  property :login, String
  property :password, String, :control => :password

Now when using the part/admin, you'll have a password input instead of a
text input.

Btw, I'm not very satified with my PasswordControl implementation
because it puts the password in clear in the html. I could do something
better if I knew a generic way to tell that the field didn't change.

   Jonas Pfenniger

More information about the Nitro-general mailing list