Max length not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krishnapriya
    Senior Member
    • Aug 2017
    • 209

    Max length not working

    Max length for first name not working in contacts.

    Please help.

    Thanks.
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    More details, please

    Comment

    • krishnapriya
      Senior Member
      • Aug 2017
      • 209

      #3
      Hi,

      Click image for larger version

Name:	contacts.png
Views:	486
Size:	13.0 KB
ID:	31381Click image for larger version

Name:	firstname.png
Views:	464
Size:	31.2 KB
ID:	31382

      I put first name max length as 2. But still I can enter more than 2 characters in firstname.

      Comment

      • krishnapriya
        Senior Member
        • Aug 2017
        • 209

        #4
        Hi Tanya, Can you help please, regarding the max length issue

        Comment

        • tanya
          Senior Member
          • Jun 2014
          • 4308

          #5
          Hello

          This parameter is used only in database > table > column > length definition (and it affects only, if value is gather, then set ). No UI validation.

          Comment

          • krishnapriya
            Senior Member
            • Aug 2017
            • 209

            #6
            Hi tanya,

            In case of all other fields, if we set max length parameter, it limits the number of entries in the UI. So is there any way we can do it for first name,last name, phone also?

            Comment

            • tanya
              Senior Member
              • Jun 2014
              • 4308

              #7
              Sorry
              I found this in code
              open client/res/templates/fields/base/edit.tpl, copy {{#if params.maxLength}} maxlength="{{params.maxLength}}"{{/if}} to
              client/res/templates/fields/person-name/edit.tpl in input attribute section

              Thanks

              Comment

              • krishnapriya
                Senior Member
                • Aug 2017
                • 209

                #8
                Still not working. :-(

                Comment


                • tanya
                  tanya commented
                  Editing a comment
                  Did you Clear Local Cache?
              • krishnapriya
                Senior Member
                • Aug 2017
                • 209

                #9
                Yes I did

                Comment

                • tanya
                  Senior Member
                  • Jun 2014
                  • 4308

                  #10
                  trl code
                  Code:
                  <div class="row">
                      <div class="col-sm-3 col-xs-3">
                          <select name="salutation{{ucName}}" class="form-control">
                              {{options salutationOptions salutationValue field='salutationName' scope=scope}}
                          </select>
                      </div>
                      <div class="col-sm-4 col-xs-4">
                          <input type="text" class="form-control" name="first{{ucName}}" value="{{firstValue}}" placeholder="{{translate 'First Name'}}" {{#if firstMaxLength}} maxlength="{{firstMaxLength}}"{{/if}}>
                      </div>
                      <div class="col-sm-5 col-xs-5">
                          <input type="text" class="form-control" name="last{{ucName}}" value="{{lastValue}}" placeholder="{{translate 'Last Name'}}" {{#if lastMaxLength}} maxlength="{{lastMaxLength}}"{{/if}}>
                      </div>
                  </div>
                  client/src/views/fields/person-name.js
                  data function
                  Code:
                         
                  data: function () {
                              var data = Dep.prototype.data.call(this);
                              data.ucName = Espo.Utils.upperCaseFirst(this.name);
                              data.salutationValue = this.model.get(this.salutationField);
                              data.firstValue = this.model.get(this.firstField);
                              data.lastValue = this.model.get(this.lastField);
                              data.salutationOptions = this.model.getFieldParam(this.salutationField, 'options');
                              data.firstMaxLength = this.model.getFieldParam(this.firstField, 'maxLength');
                              data.lastMaxLength = this.model.getFieldParam(this.lastField, 'maxLength');
                              return data;
                          },

                  Comment

                  • krishnapriya
                    Senior Member
                    • Aug 2017
                    • 209

                    #11
                    Great tanya. It worked . Thank you

                    Comment

                    Working...