Modeling condition, nested forms with elm-simple-forms -


i have form starts select. depending on selected form expands common main bit , details section depends on selection.

i started modeling separate details section

type productdetails     = book book.model     | brochure brochure.model     | card card.model  type alias model =   { form : form customerror estimate   , details : productdetails      -- form customererror cardmodel / bookmodel / ....   , msg : string   } 

but becoming quite convoluted handle in e.g. view.

the alternative seem conditionally add details main form model - e.g.

type alias estimate =   { customer : string   , project : string   , product : string   , details : productdetails   } 

before started i’d welcome experience others on has worked well

if understand correctly, have separate modules book, brochure , card? don't quite understand purpose of model structure this:

import book import brochure import card  type products     = book     | brochure     | card   type msg     = details products   type alias model =     { selectedproduct : product     }   update : msg -> model -> model update msg model =     case msg of         details prd ->             model prd   view : model -> html view model =     model.selectedproduct.view 

so can see, define available products , msg can details, show details, , it's function set selectedproduct value in model selected product. can implement selecting with:

button [ onclick (details book) ] [ text "book" ] 

for example select book. later on want make dynamic , first instinct should able call view function of selected product.

in other case define view require fields, every product's model contain , use them write information on site.

please note code above isn't meant work, it's represent idea.


Comments

Popular posts from this blog

Sass watch command compiles .scss files before full sftp upload -

filehandler - java open files not cleaned, even when the process is killed -

gridview - Yii2 DataPorivider $totalSum for a column -