SythilTech / Odoo

Odoo Modules
39 stars 113 forks source link

[html_form_builder] field required options are ignored #16

Open jbofill opened 6 years ago

jbofill commented 6 years ago

In html_form_builder there is the option to mark a form field as required. If users omit required input data and try to submit the form, a warning message show be display. Currently what happens is that no warning is shown and an error message is display later. I think in general there is some code missing.

For example in Checkbox(Boolean) function in Odoo/html_form_builder/controllers/main.py 'required' attribute is needed in input tag.:

def _generate_html_checkbox_boolean(self, field):
        """Generate Checkbox(Boolean) HTML"""
        html_output = ""
        html_output += "<div class=\"hff hff_checkbox checkbox\" data-form-type=\"" + field.field_type.html_type + "\" data-field-id=\"" + str(field.id) + "\">\n"
        html_output += "  <label"

        if field.setting_general_required is True:
            html_output += " class=\"required\""

        html_output += "><input type=\"checkbox\" name=\"" + field.html_name + "\""
        if field.setting_general_required is True:
            html_output += " required"
        html_output += "/>" + field.field_label + "</label>\n"
        html_output += "</div>\n"

        return html_output

This also is the case of dropbox, radio, etc.

SythilTech commented 6 years ago

I have released a new version, this will add the required class to the label and the required attribute for most field types which will cause the red * to appear besides the field.

Some help block text will appear if the field is not filled, however there is a known issue where this can be permanently saved and am looking into a way to revamp the required feature to avoid the problem.