Master Detail form with ILFormula

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

Master Detail form with ILFormula

thiago_sl
Hi list,
I have a widget to create/edit my Order + order items (one-to-many),
but i am not 'happy' with it.
In this widget:
1 - i can edit the order fields;
2 - create items, wich contains basically: the order fields,
product(another entity, via select field) + value(currency) + an 'Add'
button, to put in the collection order --> orderItems,;
3 - i can remove orderItems from list, too.
4 - I can Save / Cancel the whole operation.

I want to know if is possible to do that with ILFormula. I am using
ILFormula in others widget.

Cheers,
Thiago
Reply | Threaded
Open this post in threaded view
|

Re: Master Detail form with ILFormula

Nicolas Petton
Hi,

Formula doesn't support it by default. You can represent one to many
relationships with select fields or multiple checkbox, but you can't
enter add/remove elements from a collection, or edit elements in the
collection the formula.

The ILField>>addRow: method allows you to add extra content to fields,
including an anchor to show another formula ;)

So you can add something like this:

formula := ILFormula on: myModel.

(formula multipleCheckBoxOn: #items)
    label: 'Items';
    ...;
    ...;
    addRow: [:e |
        e a
            text: 'Add a new item';
            action: [formula
                show: (ILFormula on: MyItem new)
                onAnswer: [:ans | ans ifNotNil: [
                    formula proxy items add: ans]]]]


This example adds a link after the multiple checkbox field to display a
formula widget for a new item to be added to the collection.

I didn't test the code, but it should work out of the box.
Note that the new item is added to the proxy, not directly to the model,
so the user can cancel the changes without keeping the new item in the
collection.

Cheers,
Nico

Le lundi 28 mars 2011 à 09:18 -0700, Thiago SL a écrit :

> Hi list,
> I have a widget to create/edit my Order + order items (one-to-many),
> but i am not 'happy' with it.
> In this widget:
> 1 - i can edit the order fields;
> 2 - create items, wich contains basically: the order fields,
> product(another entity, via select field) + value(currency) + an 'Add'
> button, to put in the collection order --> orderItems,;
> 3 - i can remove orderItems from list, too.
> 4 - I can Save / Cancel the whole operation.
>
> I want to know if is possible to do that with ILFormula. I am using
> ILFormula in others widget.
>
> Cheers,
> Thiago