Search code examples
w2ui

Is it possible to have a date input in a w2ui toolbar


I am wondering if there is any way one could place a date input control in a toolbar similar to the one used for date input on a form?


Solution

  • Yes, it's possible, but it's quirky.

    You will have to define the input field as a toolbar button:

    { type: 'html',   id: 'roles', html: '<input id="id_role">' },
    

    and in the toolbar's onRefresh() event you will have to cast the input to the desired w2filed:

            onRefresh: function(event) {
                if(event.target == 'roles'){
                    // w2field in toolbar must be initialized during refresh
                    // see: https://github.com/vitmalina/w2ui/issues/886
                    event.onComplete = function(ev){
                        $("#id_role").w2field('list', { items: roles });
                    };
                }
            },
    

    In my example I'm inserting a drop down list, but you can adjust it to your needs.

    Please see https://github.com/vitmalina/w2ui/issues/886 for an "official" reply.