Creating a form using Magritte

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating a form using Magritte

Rogier Schaaf
Hi,

I'm trying to get an HTML form working for a model object using Pharo 4 and Seaside 3. 

The model is a simple Address class with 3 instance variables: street, postCode and town. I have added the Magritte description methods like so:

magritteDescriptionPostCode
<magritteDescription>
^ MAStringDescription new
accessor: #postCode;
label: 'Postcode';
priority: 250;
yourself

The form is a subclass of WAComponent. It has the following method:

renderContentOn: html
( Address new asComponent
addValidatedForm: { #save -> 'Save'. #cancel -> 'Cancel' };
yourself ) renderContentOn: html

The form displays in the browser but has no Save / Cancel buttons and the form tags are missing as well.

What am I missing?

Thanks for your help.

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Creating a form using Magritte

JupiterJones
Hi Rogier,

I think this might be all you need.

renderContentOn: html
        html render: ( Address new asComponent
                addValidatedForm;
                yourself )

Hope it works for you :)

Cheers,

J

> On 28 May 2015, at 8:40 am, Rogier Schaaf <[hidden email]> wrote:
>
> Hi,
>
> I'm trying to get an HTML form working for a model object using Pharo 4 and Seaside 3.
>
> The model is a simple Address class with 3 instance variables: street, postCode and town. I have added the Magritte description methods like so:
>
> magritteDescriptionPostCode
> <magritteDescription>
> ^ MAStringDescription new
> accessor: #postCode;
> label: 'Postcode';
> priority: 250;
> yourself
>
> The form is a subclass of WAComponent. It has the following method:
>
> renderContentOn: html
> ( Address new asComponent
> addValidatedForm: { #save -> 'Save'. #cancel -> 'Cancel' };
> yourself ) renderContentOn: html
>
> The form displays in the browser but has no Save / Cancel buttons and the form tags are missing as well.
>
> What am I missing?
>
> Thanks for your help.
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Creating a form using Magritte

Mariano Martinez Peck
In reply to this post by Rogier Schaaf


On Wed, May 27, 2015 at 7:40 PM, Rogier Schaaf <[hidden email]> wrote:
Hi,

I'm trying to get an HTML form working for a model object using Pharo 4 and Seaside 3. 

The model is a simple Address class with 3 instance variables: street, postCode and town. I have added the Magritte description methods like so:

magritteDescriptionPostCode
<magritteDescription>
^ MAStringDescription new
accessor: #postCode;
label: 'Postcode';
priority: 250;
yourself

The form is a subclass of WAComponent. It has the following method:

renderContentOn: html
( Address new asComponent
addValidatedForm: { #save -> 'Save'. #cancel -> 'Cancel' };
yourself ) renderContentOn: html


mmm that code looks wrong. You should never send explicit #renderContentOn:
Instead, you should use #render:

renderContentOn: html
html render: ( Address new asComponent
addValidatedForm: { #save -> 'Save'. #cancel -> 'Cancel' };
yourself ) 

Did it change? 

Cheers, 

 
The form displays in the browser but has no Save / Cancel buttons and the form tags are missing as well.

What am I missing?

Thanks for your help.

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki



--

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Creating a form using Magritte

Rogier Schaaf
Thanks to both Mariano and Jupiter for your help. It works!

On 27 May 2015 at 23:50, Mariano Martinez Peck <[hidden email]> wrote:


On Wed, May 27, 2015 at 7:40 PM, Rogier Schaaf <[hidden email]> wrote:
Hi,

I'm trying to get an HTML form working for a model object using Pharo 4 and Seaside 3. 

The model is a simple Address class with 3 instance variables: street, postCode and town. I have added the Magritte description methods like so:

magritteDescriptionPostCode
<magritteDescription>
^ MAStringDescription new
accessor: #postCode;
label: 'Postcode';
priority: 250;
yourself

The form is a subclass of WAComponent. It has the following method:

renderContentOn: html
( Address new asComponent
addValidatedForm: { #save -> 'Save'. #cancel -> 'Cancel' };
yourself ) renderContentOn: html


mmm that code looks wrong. You should never send explicit #renderContentOn:
Instead, you should use #render:

renderContentOn: html
html render: ( Address new asComponent
addValidatedForm: { #save -> 'Save'. #cancel -> 'Cancel' };
yourself ) 

Did it change? 

Cheers, 

 
The form displays in the browser but has no Save / Cancel buttons and the form tags are missing as well.

What am I missing?

Thanks for your help.

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki



--

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki