[Seaside] Type conversions for form models using WALabelledFormDialog subclasses

Avi Bryant avi at beta4.com
Thu Sep 30 19:39:39 CEST 2004


On Sep 30, 2004, at 7:11 PM, Yar Hwee Boon wrote:

> Hi all,
>
> Is there a convenient way to peform type conversions (eg. Number <-> 
> String) on a form model? Thanks.

The built in textInput methods (ie, #textInputWithValue:callback:) try 
to be pretty smart about this.  You can give them anything and it'll 
display asString, except nil which will display as an empty string. If 
you give them a number as the value, they'll give you a number back in 
the callback.  If you give them a string, you'll get a string back, 
including possibly an empty string.  If you give them a nil, you'll get 
back either a non-empty string (if the user enters one) or nil (if the 
user enters an empty string).

If you needed some other type conversion, I would write your own 
version of #textInputWithValue:callback:, using the existing one as a 
model, and use it where appropriate.

Avi



More information about the Seaside mailing list