Skip to content

Cannot hide field if field title contains parentheses #6

@sh67

Description

@sh67

Describe the bug
When a field title contains a pair of parentheses, like Enter ABC (or DEF), the Fields.hide method does not work.

To Reproduce
Steps to reproduce the behavior:

  1. Assign a field title containing a pair of parentheses, like Enter ABC (or DEF).
  2. Call the Fields.hide method on the field, like Fields.hide("Enter ABC (or DEF)").

Expected behavior
The field should be hidden.

Desktop (please complete the following information):

  • OS: Win 10 (64-bit)
  • Browser: Internet Explorer
  • Version: 11

Additional context
I suspect it's falling down in the getCell method where the title is passed in as a regex pattern for matching, and the parentheses are being interpreted as a regex grouping. (When stepping through the code in the debugger, html comes back as null on this field.)

  getCell: function (fieldDisplayName) {
    var theCell = $(".ms-formbody").filter(function (i, o) {
      var rx = 'FieldName=\"' + fieldDisplayName + '\"';
       var html = o.innerHTML.match(new RegExp(rx));  <--- maybe here?
      return html !== null; // && html.length > 0;
    });
    return theCell;
  },

Workaround
Currently I'm working around this by removing the parentheses from the field title.

Proposed Solution
I apologize, but I should mention that I haven't given any thought as to what a solution might look like.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions