django-dynamic-forms icon indicating copy to clipboard operation
django-dynamic-forms copied to clipboard

boolean field always ask for true value

Open bedros opened this issue 10 years ago • 6 comments

When I create a boolean field, it will not accept the form unless I set it to TRUE.

bedros avatar Dec 17 '15 06:12 bedros

Obviously, please set required=False according to the Django docs

MarkusH avatar Dec 17 '15 09:12 MarkusH

actually, I'm aware that you can set required=false; however the example project does not accept the boolean field unless its value entered is true, making the example project not functioning correctly unless the user edits the project.

bedros avatar Dec 17 '15 18:12 bedros

Ah, that sounds legit.

MarkusH avatar Jan 01 '16 11:01 MarkusH

I have a similar issue. Boolean fields always require to be ticked for the form to submit. In the code I discovered this:

@dynamic_form_field
class BooleanField(BaseDynamicFormField):

    cls = 'django.forms.BooleanField'
    display_label = _('Boolean')

    class Meta:
        _exclude = ('required',)

Removing the Meta completely fixes the issue because I can decide on my own if the field is required to be ticked or can be left blank. Now I don't really understand why that exclude was added and would suggest to remove it.

dcale avatar May 13 '16 11:05 dcale

Do you want to provide a pull request + patch for that? Happy to review it :smile:

MarkusH avatar Jun 02 '16 17:06 MarkusH

after thinking about a use case; I think it's right the way it's right now.

Example,

a form may have boolean at end of the form for the following question

check here X to accept the agreement; the checkbox must be True for the form to be submitted successfully, therefore, in this case, the developer sets this booleanfield as required. and it should only be accepted if it's value is True, the same as current behavior

bedros avatar Nov 09 '16 00:11 bedros