Render field view without model

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SuperEwald
    Junior Member
    • Jun 2018
    • 9

    Render field view without model

    Hi there,

    I'm currently trying to create a modal which should contain two date input fields to let user choose a period. Since the period is not related to a specific entity I want to render the date fields without passing a model. It seems to me this is currently not possible as the view always complains about the missing model (which I set to null).

    Is there any way to render a field view without passing a model instance ?

    Just for reference, this is what I'm trying to do:

    Code:
    define('academy:views/modals/date-range-picker', ['views/modal'], function (Dep) {
        return Dep.extend({
            className: 'dialog dialog-record',
           // template content can be defined right here or externally
           templateContent: '<div class="startDate">{{{startDate}}}</div><div class="endDate">{{{endDate}}}</div>',
           setup: function () {
               this.createView('startDate', 'views/fields/date', {
                   model: null,
                   el: this.getSelector() + ' .startDate'
               });
               this.createView('endDate', 'views/fields/date', {
                   model: null,
                   el: this.getSelector() + ' .endDate'
               });
           },
        })
    });
    Thanks in advance!
  • yuri
    Member
    • Mar 2014
    • 8453

    #2
    You need to create a model anyway. It doesn't need to correspond an entity type. Just require a model class and create it using "new".



    I recommend taking look into code.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • SuperEwald
      Junior Member
      • Jun 2018
      • 9

      #3
      Thanks alot, does work like intended!

      I tried to look for similar code but didn't find it (seems like I didn't look deeply enough). Sorry for that stupid question.

      Comment

      Working...