Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

[FormBuilder] Add supports for related fields #7

@MangelMaxime

Description

@MangelMaxime

Issue by MangelMaxime
Thursday Nov 29, 2018 at 12:37 GMT
Originally opened as MangelMaxime/Thoth#94


From @tforkmann on Gitter

I'm just trying out your FormBuilder. Its very cool! Is it possible to use the value of an already selected field for the next form element?

Sure! 1. Field: Select Plant get data from backend 2.field: take selected key from 1. field and get data from the backend using the selected key. That's what i have so far:

let formState, formConfig =
    Form<Msg>
        .Create(OnFormMsg)
        .AddField(
            BasicSelect
                .Create("selectPlant")
                .WithLabel("Anlagenauswahl")
                .WithValuesFromServer(getPlants) //Selected Key = PlantId
                .WithPlaceholder("")
                .IsRequired("Bitte wählen Sie eine Anlage aus!")
                .WithDefaultView()
        )
        .AddField(
            BasicSelect
                .Create("selectMeter")
                .WithLabel("Zählerauswahl")
                .WithValuesFromServer(getMeters "4" ) // -> Replace "4" with Selected PlantId in selectPlant Field
                .WithPlaceholder("")
                .IsRequired("Bitte wählen Sie einen Zähler aus!")
                .WithDefaultView()
        )
        .Build()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions