How to get a value from another Livebook cell of a Kino.Control.form

I know how to create an Input in one cell like

input = Kino.Input.checkbox("Input")

Then in another cell later get the value.

value = Kino.Input.read(input)

But I’m confused about forms.

In Livebook when you insert a Block → Form you get this code.

form =
  Kino.Control.form(
    [
      name: Kino.Input.text("Name")
    ],
    submit: "Submit"
  )

Kino.listen(form, fn event ->
  IO.inspect(event)
end)

form

How would I get the values in other cells later in lavebook?

Thanks

1 Like

Forms are event-driven, which means you can’t read their current value and instead you can receive an event whenever the form is submitted. In the snippet above we subscribe to the form with:

Kino.listen(form, fn event ->
  IO.inspect(event)
end)

When you submit the form, this callback will run and event.data will be %{name: "..."}.

1 Like