Announcement

Collapse
No announcement yet.

Person name

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

  • Person name

    Hi,

    I need to set firstName as 'required' when type is '2'

    Click image for larger version

Name:	mandatory.png
Views:	1
Size:	12.9 KB
ID:	31526
    I used dynamic logic and only mandatory sign (*) comes on selecting type 2, but no validation when clicking Save button without data.
    Even <input type="text" class="form-control" name="first{{ucName}}" value="{{firstValue}}" placeholder="{{translate 'First Name'}}" required="true"> not working


    Please help

  • #2
    https://github.com/espocrm/documenta...namic-forms.md also tried not working.

    For any other fields dynamic logic works fine.

    If I add firstname separately to the layout, then also it is working fine.

    Click image for larger version

Name:	mandatory.png
Views:	1
Size:	14.5 KB
ID:	31528
    so what happens with name field?

    Please help.

    Comment


    • #3
      Hello

      You add on detail view 'name' field. For dynamic logic there are no "firstName" field, only "name" field.

      Comment


      • #4
        Hi,

        For name also I have added dynamic logic. still not working Click image for larger version

Name:	mandatory.png
Views:	1
Size:	16.5 KB
ID:	31533

        Comment


        • #5
          Hi,

          Visibility and read only dynamic logic works for name.
          Only the required logic is not working.
          Please help.

          Comment


          • #6
            client/src/views/fields/person-name.js

            replace there functions with this code
            Code:
                    validateRequired: function () {
                        var result = false;
                        var isRequired = Dep.prototype.isRequired.call(this);
                        var nameValue = this.model.get(this.salutationField) + this.model.get(this.firstField) + this.model.get(this.lastField);
            
                        if (isRequired && nameValue === '') {
                            var msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.translate(this.name, 'fields', this.model.name));
                            this.showValidationMessage(msg, '[name="'+this.lastField+'"]');
                            result = true;
                        }
                        var validate = function (name) {
                            if (this.model.isRequired(name)) {
                                if (this.model.get(name) === '') {
                                    var msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.translate(this.name, 'fields', this.model.name));
                                    this.showValidationMessage(msg, '[name="'+name+'"]');
                                    return true;
                                }
                            }
                        }.bind(this);
            
                        result = validate(this.salutationField) || result;
                        result = validate(this.firstField) || result;
                        result = validate(this.lastField) || result;
                        return result;
                    },
            
                    isRequired: function () {
                        return Dep.prototype.isRequired.call(this) ||
                               this.model.getFieldParam(this.salutationField, 'required') ||
                               this.model.getFieldParam(this.firstField, 'required') ||
                               this.model.getFieldParam(this.lastField, 'required');
                    },

            Comment


            • #7
              Hi Tanya,

              Working Perfect. Thank you

              Comment

              Working...
              X