Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditTable: customizing the input should allow row in parameters #543

Open
boxed opened this issue Jul 5, 2024 · 1 comment
Open

EditTable: customizing the input should allow row in parameters #543

boxed opened this issue Jul 5, 2024 · 1 comment

Comments

@boxed
Copy link
Collaborator

boxed commented Jul 5, 2024

I was trying to write documentation for EditTable:

@pytest.mark.django_db
def test_edit_table_attrs_on_field(small_discography):
    edit_table = EditTable(
        auto__model=Album,
        columns__year__field=dict(
            include=True,
            input__attrs__class__the_best_year=lambda row, **_: row.year == 1980,
        ),
        # edit_form__fields__year__input__attrs__class__the_best_year=lambda **_: 'the_best_year',

    )

    output = edit_table.bind(request=req('get')).render_to_response().content.decode()
    assert 'the_best_year' in output

But this unfortunately crashes with:

 AssertionError: Evaluating lambda found at: `input__attrs__class__the_best_year=lambda row, **_: row.year == 1980,` didn't resolve it into a value but strict mode was active, the signature doesn't match the given parameters. We had these arguments: request, user, table, traversable, form, instance, field, fragment
@boxed
Copy link
Collaborator Author

boxed commented Jul 5, 2024

I was trying to add this to the docs:

def test_edit_tables_field_customization(big_discography):
    # language=rst
    """
    Field customization
    -------------------

    The `field` namespace on an `EditColumn` is an iommi `Field` instance, same as any normal `Form`, so can be customized in the same way:
    """

    # @test
    t = (
    # @end

    EditTable(
        auto__model=Album,
        page_size=10,
        columns__year__field=dict(
            include=True,
            attrs__placeholder='year',
            attrs__style__background='grey',
            attrs__class__foo=True,
        ),
    )

    # @test
    )

    show_output(t.bind(request=request))
    # @end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant