Skip to content

Line editor

Rows of a model inside a form, with totals.

Example

Lines

Line #ItemQuantityUnit priceTotalActions
11,004.28
2500.00
Total1,504.28

Show code
use zeyn::prelude::*;

pub fn overview(_ctx: &Ctx) -> Node {
    Form::of(Invoice {
        customer: "Northwind".into(),
        lines: vec![
            Line { item: "Notebook".into(), quantity: 12, unit_price: Money::tl(8_369) },
            Line { item: "Pencil".into(), quantity: 40, unit_price: Money::tl(1_250) },
        ],
    })
    .field(Invoice::customer)
    .lines(Invoice::lines, |l| {
        l.column(Line::item)
            .column(Line::quantity)
            .column(Line::unit_price)
            .total(Line::quantity, Line::unit_price)
    })
    .submit("Save", total_invoice)
    .on_success(|_, ui| ui.toast("Saved. Nothing was stored."))
    .into()
}