createField

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

    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
    Member
    • Mar 2014
    • 8627

    #2
    What value is in model's exportDate attribute. console.log(model.get('exportDate')). Is it defined?
    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

    • caffeine
      Member
      • Aug 2014
      • 48

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

      Comment

      • yuri
        Member
        • Mar 2014
        • 8627

        #4
        You get None because field is not set?
        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

        • 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
              Member
              • Mar 2014
              • 8627

              #7
              Date is stored in system format and UTC Timezone, and converted for view using DateTime class and moment lib.
              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

              • 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
                  Member
                  • Mar 2014
                  • 8627

                  #9
                  mode: 'edit'
                  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

                  Working...