Announcement

Collapse
No announcement yet.

Render field view without model

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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!

  • #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".

    https://docs.espocrm.com/development/modal/

    I recommend taking look into code.

    Comment


    • #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...
      X