createField

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • caffeine
    Member
    • Aug 2014
    • 48

    #1

    createField

    Hi, I'm trying to create a date field that is not in the entityDefs for a sidepanel, I'm using:

    PHP Code:
    this.createField('exportDate', null, null, 'Fields.DatetimeShort'); 
    
    and:

    PHP Code:
    createField: function (name, type, params, view) {            
                type = type || this.model.getFieldType(name) || 'base';        
                this.createView(name, view || this.getFieldManager().getViewName(type), {
                    model: this.model,
                    defs: {
                        name: name,
                        params: params || {}
                    },
                    el: this.options.el + ' .cell-' + name,
                    mode: 'list'
                });
                
            }, 
    
    But I'm always getting a 'None' result, what I'm missing?

    Thanks
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9794

    #2
    What value is in model's exportDate attribute. console.log(model.get('exportDate')). Is it defined?

    Comment

    • caffeine
      Member
      • Aug 2014
      • 48

      #3
      No, it seems that it's not defined, I get side.js error.

      Comment

      • yuri
        EspoCRM product developer
        • Mar 2014
        • 9794

        #4
        You get None because field is not set?

        Comment

        • caffeine
          Member
          • Aug 2014
          • 48

          #5
          You are correct, I added to my json:

          PHP Code:
          "exportDate": {
                      "type": "datetime",
                      "required": false,
                      "notStorable": true,
                      "db": false
                  } 
          
          and call with:
          PHP Code:
          this.createField('exportDate', false); 
          
          It's possible to force the field into "Edit Mode", I have to click the pencil everytime I need to edit it.

          Thank you for your help.

          Comment

          • caffeine
            Member
            • Aug 2014
            • 48

            #6
            Something strange happens with the date:

            For example I set the date to: 08.10.2014 17:00

            When I log the date I got: 2014-10-08 15:00:00

            For some reason I get 2 hours less when I log it, I assume that has something to do with my timezone.

            Comment

            • yuri
              EspoCRM product developer
              • Mar 2014
              • 9794

              #7
              Date is stored in system format and UTC Timezone, and converted for view using DateTime class and moment lib.

              Comment

              • caffeine
                Member
                • Aug 2014
                • 48

                #8
                It's possible to force the field into edit mode instead of clicking on the pencil everytime?

                Thanks

                Comment

                • yuri
                  EspoCRM product developer
                  • Mar 2014
                  • 9794

                  #9
                  mode: 'edit'

                  Comment

                  Working...