Could you provide us some code - not necessarily working - with what you are trying to do? Thanks.

By on 5/7/2013 7:56 AM ()

Thanks for your answer.

Here is a simplified example.

My goal is to provide a list with the contacts that already exist.

I get a Contact list from C# MVC (works fine, all the values are passed to the javascript).

I expected the InitWith to populate the UI with the contacts.

The actual result shows a unique empty record.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
type Contact =
    {
        Id: int
        TypeContact: int
        Number: string
    }

type Contacts =
    {
        Contacts: List<Contact>
    }

module ContactsPagelets =

    [<JavaScript>]
    let ContactsFormlet (contacts : Contacts) =
        let principalF : Formlet<Contact> =
            let TypeContactF =
                Select 0 [("Phone", 0); ("Email", 1)]
                |> Enhance.WithTextLabel "Type"
            let NumberF =
                Input ""
                |> Enhance.WithTextLabel "Number"
            Formlet.Yield (fun typeId number->
                {Id = 0 ; TypeContact = int typeId; Number = number})
            <*> TypeContactF
            <*> NumberF
        let itemsF =
            principalF
            |> Enhance.Many 
            |> Formlet.InitWith contacts.Contacts
            |> Enhance.WithLegend "Contacts"
            |> Enhance.WithErrorSummary "Errors"
        Formlet.Yield (fun items ->
                {
                    Contacts = items
                }
            )
        <*> itemsF
        |> Enhance.WithSubmitButton
        |> Enhance.WithFormContainer

type ContactControl() =
    inherit Web.Control()

    [<DefaultValue>]
    val mutable Contacts : Contacts

    [<JavaScript>]
    override this.Body = upcast (ContactsPagelets.ContactsFormlet this.Contacts)
By on 5/7/2013 8:38 AM ()

Thanks for the example.

Upon reading the source code of Formlet libs, it seems that Formlet.InitWith does not do what you intend it to do - it does not work even on a simple formlet such as Control.Input. It sets up initial logical state but there is no feedback from logical state to visual state, only in reverse.

While it is an entirely reasonable requirement, as far as I can tell current formlets are not designed to do this. I have been recently working on a prototype Formlet replacement library, and will definitely include this as one of requirements.

By on 5/9/2013 5:23 AM ()

Thank you Anton for your feedback, so I will wait for that library...

By on 5/10/2013 5:04 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper