Edit tables

How do you edit one-to-one fields in an edit table?

Include them in auto__include. Say you have a profile model for an artist:

Then you can include the artist name field:

edit_table = EditTable(
    auto__model=Profile,
    auto__include=['artist__name'],
    columns__artist_name__field__include=True,
)
▼ Hide result
Toggle structure

How do I change the delete buttons to checkboxes?

Just add data-iommi-edit-table-delete-with="checkbox":

edit_table = EditTable(
    auto__model=Profile,
    auto__include=['artist__name'],
    columns__artist_name__field__include=True,
    columns__delete=EditColumn.delete(),
    **{
        'attrs__data-iommi-edit-table-delete-with': 'checkbox',
    }
)
▼ Hide result
Toggle structure

How do I include labels for fields?

If you’re using EditTable and not EditTable.div, then by default you get fields rendered without labels, because the label text is in the table header. But in case you still want to render labels (e.g. as floating labels), you can just set extra_evaluated__input_labels_include = True:

edit_table = EditTable(
    auto__model=Profile,
    auto__include=['artist__name'],
    columns__artist_name__field__include=True,
    extra_evaluated__input_labels_include=True,
)
▼ Hide result
Toggle structure