Jump to content

HTML5 required form field attributes only for text inputs?


Recommended Posts

I have built a simple process module that allows users to create new pages; so far, so easy.

Now I noticed something strange, and I'm not sure if I miss something, but it seems inconsistent to me: Text-based input fields get the HTML5 attribute required="required" and it works as expected.

However, for selects (InputfieldPage, InputfieldAsmSelect) PW only injects a CSS class "required", but doesn't set required="required".

Example code:

        $field                 = $this->modules->get('InputfieldPage');
        $field->inputfield     = 'InputfieldAsmSelect';
        $field->parent_id      = 1221;
        $field->labelFieldName = 'title';
        $field->name           = 'service';
        $field->label          = 'Dienstleistungen';
        $field->required       = true;
        $field->setAttribute('required', 'required');
        $field->columnWidth = 33;
        $field->collapsed   = 9;

I know I could create a hook and inject that attribute (maybe something like this?), but it seems like overkill, when we can already configure the fields. Am I missing something obvious here?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...