Adding attributes for fields using ejs view helpers

360 views Asked by At

I am using ejs template rendering

<%- input_field_tag('inputFld', 5) %>

This code generates input field as

<input id="inputFld" value="" type="5" name="inputFld">

Now I want id and name attribute different ie. id="inputFldID" and name="inputFldName" also I want to add class attribute.

How should I achieve this?

1

There are 1 answers

0
Aleksandr M On BEST ANSWER

You are probably looking for text_field_tag, because type="5" doesn't make much sense.

You can pass object as third argument to text_field_tag with attributes you want to set.

<%- text_field_tag('inputFld', '5', {id: 'inputFldId', Class: 'some_class'}) %>