You are viewing limited content. For full access, please sign in.

Question

Question

How to auto adjust multiline fields in Forms new Modern Designer?

asked on July 7, 2023 Show version history

I found this code that was helpful for Classic Designer, but not the new Modern Designer. 

 

$( document ).ready(function() {

  /* call autoGrowML function on existing fields on canvas */

  autoGrowML();

 

  /* ensure that autoGrowML function is applied to any textAreas that appear as a result of a new table row or new colletion item */

  $('.cf-table-add-row, .cf-collection-append').on('click', function() {

    autoGrowML();

  });

 

});

 

function autoGrowML() {

  /* Iterate through each textarea with autoGrow class and call function to expand/contract with amount of text entered */

  $('.autoGrow textarea').each(function () {

    h(this);

  }).on('lookup change keyup', function () {

    h(this);

  });

}

 

function h(e) {

  /* Function that actually performs the expansion/contraction of specified fields */

  $(e).css({'height':'auto','overflow-y':'hidden','min-height':'26px'}).height(e.scrollHeight);

}

 

 

Does anyone know of the code that will auto adjusted the size of my multiline fields in Modern Designer? 

0 0

Replies

replied on July 7, 2023

Please note that you can use the code button (looks like {....} with the word code) to make code snippets easier to read in posts and comments.

Unfortunately, any code written for the Classic Designer isn't going to work on the Layout Designer without serious modification, for several reasons:

  1. The Form structure on the Layout Designer is drastically different than the structure of form in the Classic Designer.
  2. The Javascript on the Layout Designer uses vanilla Javascript, not JQuery like the Classic Designer.
  3. Most importantly, the Javascript on the Layout Designer runs within a Sandboxed iFrame, and does not have direct access to the document, form, fields, attributes, etc.  The only parts of the form and fields that can be edited are those that have been made available via the LFForm Object (also known as the LFForm Interface) which you can read about in the help files (here's a link).  Unfortunately, that means we can't do things like edit attributes of a field, unless they are specifically set-up in the LFForm Object.

 

Unfortunately, in this case, I don't think there is a way around these limitations in order to achieve your goal.

This discussion includes several items that users would like to see included in future releases of the Forms Layout Designer, and this particular comment on the discussion is specifically addressing this functionality with auto-growing multi-line fields.  I would recommend upvoting that comment and also replying that you would appreciate that functionality as well.

5 0
You are not allowed to follow up in this post.

Sign in to reply to this post.