Using HTML5 input types (e.g. date)

Using HTML5 input types (e.g. date)

by Mike Churchward -
Number of replies: 2
Picture of Core developers Picture of Plugin developers Picture of Testers

I'm considering using HTML5 inputs, in particular the date input type. The downside of this is that its not supported in a couple of browsers (IE, Safari). But, when not supported, it defaults to a text input, which is what would be used if I didn't use the date type.

Is there a good reason not to use this that I'm not thinking of?

Another issue, the Travis CI test for mustache templates (moodle-plugin-ci mustache) fails when I use the date type:

"WARNING: HTML Validation info, line 5: The “date” input type is not supported in all browsers. Please be sure to test, and consider using a polyfill."

Anyone know how I could get past that?

Average of ratings: -
In reply to Mike Churchward

Re: Using HTML5 input types (e.g. date)

by Darko Miletić -
To adres your second concern you could do something like this:

{{!
    @template mod_myplugin/foo

    This template renders something .

    Example context (json):
    {
        "inputs": [
          {"type": "text", "text": "foo", "title": "foo"},
          {"type": "text", "text": "foo", "title": "foo"}
        ]
    }
}}

<div class="mod_myplugin_foo">
{{#inputs}}
  <input type="{{type}}" title="{{title}}">{{text}}</input>
{{/inputs}}
</div>

In mustache test data you provide text as type of input while in your code you do whatever you want.

Average of ratings: Useful (1)