Hi @richardelovia
Thank you for response and additional information!
The way you tried to achieve this will not work and there are two reasons for that:
– even though you are putting HTML code into HTML field, there’s only a limited set of HTML tags that can be used there and “input” is not one of them; this is related to security – field content is sanitized and some tags are stripped out of it to prevent possible XSS and similar “injection” attacks.
– even if it would be allowed, Forminator wouldn’t really process such field and save it, it’s a bit more complex to handle fields.
We’ll need to take slightly different approach then and just change the type of field “on the fly” before it’s rendered, server-side. Here’s how to do this:
1. instead of using HTML field with HTML code in it, simply put a new field of “input” type on the form (edit form, click on “add field” and select “input” one);
drag and drop the field where you want it to show;
let’s say that the new input field that you added is {text1} field
2. create empty file with a .php extension (e.g. “forminator-input-time-field.php”)
3. copy this code and paste it into that file:
<?php
add_filter( 'forminator_field_text_markup', 'wpmu_input_type_time', 10, 2 );
function wpmu_input_type_time( $html, $field ) {
if ( 'text-1' == $field['element_id'] ) {
$html = str_replace( 'type="text"', 'type="time"', $html );
}
return $html;
}
4. in this line
if ( 'text-1' == $field['element_id'] ) {
adjust text-1 string to match your input field ID (but without curly brackets!)
5. save the file and upload it to the “/wp-content/mu-plugins” folder of your WordPress installation
That’s it. It will automatically change the type=text of the {text-1} input field to type=time and it will do this before the form markup is even sent to the browser so it should work with every browser/device that supports type=time input fields.
Best regards,
Adam