Question

How do i define an textarea as required with mojolicious tag helper?

I need to generate a textarea like this

<textarea name="comment" required></textarea>

When trying to do the same with tag helper

%= text_area 'comment', 'required'

I get

<textarea name="comment">required</textarea>
Was it helpful?

Solution

Mojo tag helpers will simply pass extra attributes through (see sub _tag in the source).

In HTML5, an empty attribute can be declared as attr="" (docs here).

So, based on the Mojo text_area docs, the syntax would be:

%= text_area 'comment', required => ''

OTHER TIPS

%= text_area 'comment', required => '1'

here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top