Change dinamically the type of an input field


I need 2 input fields, and they can be of two types, date or text, depending of dinamic variables
I am trying to use this when I have the info of the type of field that I need

$$(id_campo).define("view", "datepicker");

The label define is working great, but the view define is not working. Are there any solution for this?



define(“view”, “datepicker”) won’t work. You need to rebuild layout. However, I would advise to create both views and use hide() / show() methods to switch between views.

{view:“form”,…, elements:[
{view:“text”, id:“id_campo_text”, …},
{view:“datepicker”, id:“id_campo_datepicker”, hidden:true,…}