[Seaside] Collecting form input
ryan
ryan at intgo.net
Wed Oct 8 09:22:59 UTC 2008
Those instance variables, they are temporary variables.
Instance variables are declared in the class declaration something like.
WAComponent subclass: #addUserForm
instanceVariableNames: 'newName newSalutation'
classVariableNames: ''
poolDictionaries: ''
category: 'MyProject'
-------------
renderContentOn: html
html
form: [
html textInput value: 'type name here';
callback: [:name | newName := name].
html select list: salutations;
callback: [:userSalutation| newSalutation := userSalutation ];
labels: [:userSalutation | userSalutation asString].
html submitButton
callback: [self addUserNamed: newName withSalutation: newSalutation];
value: 'Add New User']
Should work fine.
You might be interested in looking at using something like Ramon Leon's
SSForms available in his image that you can download from his blog (http://onsmalltalk.com/)
or Magritte to help you build forms complete with validation.
On Wed, 2008-10-08 at 10:28 +0200, Sebastian Nozzi wrote:
> Hi Phillipe,
>
> thanks for your reply.
>
> > You could also use ValueHolders but that gets quite ugly. I'd use
> > instance variables and split it up.
>
> I'll look into ValueHolders (never heard of them; but I'm a newbie... so...)
>
> What do you mean by the latter? Because it was with instance variables
> that I first tried, but as I said it didn't work:
>
> | newName newSalutation |
> html
> form: [html textInput value: 'type name here';
> callback: [:name | newName := name].
> html select list: salutations;
> callback: [:userSalutation| newSalutation :=
> userSalutation ];
> labels: [:userSalutation | userSalutation asString].
> html submitButton
> callback: [self addUserNamed: newName
> withSalutation: newSalutation];
> value: 'Add New User']
>
> When the callback in the submitButton was called, "newName" and
> "newSalutation" were nil.
>
> What I was trying to do is to avoid creating a temporary user
> instance, and only create it when the user submits the data (the user
> could instead opt to go back).
>
> But I think I might be overcomplicating things and I might just create
> the temporary instance, since I'm creating a Dictionary anyway...
>
> Greetings,
>
> Sebastian
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
More information about the seaside
mailing list