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

[Bug] Image field required during upload in spite of using a conditional __required with a lambda function #554

Open
akhileshThapliyal opened this issue Aug 10, 2024 · 0 comments

Comments

@akhileshThapliyal
Copy link

akhileshThapliyal commented Aug 10, 2024

I have a scenario where I want to prompt users to upload their profile picture in create mode. Once the user uploads a profile picture and edits the other form fields such as country etc.. it should allow the form validation to pass without making the profile picture field mandatory.

Expectation is based on the condition below it should only make the field mandatory on create, and on edit, it should allow to pass the form validation for the profile picture field without the need to re-upload it, as the details are already present in the form.

Django + Iommi Playground: https://github.com/akhileshThapliyal/django_plaground

onCreate

image

onEdit

image

Profile Image Field Configuration

fields__profile_image=Field.image(
    template='user_app/profile_image_row.html',
    input__attrs={
        "id": "image-file-upload",
        "class": {
            "d-none": True
        }
    },
    required=lambda form, **_: form.instance is None
 )
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