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

Question

Question

How do i Disable/Enable Fields in a Repeating Collection

asked on August 14, 2014 Show version history

Laserfiche Version Used: 9.0.3

 

Firstly, We recently acquired Laserfiche, and are currently in the process of developing our process/workflows to begin utilizing Laserfiche. I have little to no experience regarding CSS, JS, or JQuery, and the information i have gathered is from extensive research on "Laserfiche Answers", Google, and Trial & Error.. 

 

I have a LF Forms form setup to enter in Change Notices regarding customer parts (Manufacturing Company), A portion of the information remains static, But a large majority of it can be single or multiple (IE, multiple part numbers, Each with their own changes, revisions, etc...) That information is currently setup in a collection. The collection is organised with some CSS code

 

/* Setting Initial Form Size */
 .cf-formwrap {
    width: 1020px;
}
/* Setting Collection Size */
 #q1 .cf-collection {
    width: 1000px;
}
/*Q3 Part Number*/
 #q3 .cf-field {
    width: 120px;
    min-width: 50px;
    vertical-align: top;
}
#q3 input {
    width: 120px;
}
#q3 label.cf-label {
    width: 100px;
}
/*Q4 Part Description*/
 #q4 .cf-field {
    width: 250px;
    min-width: 50px;
}
#q4 input {
    width: 250px;
}
#q4 label.cf-label {
    width: 120px;
}
/*Q5 Old Revision*/
 #q5 .cf-field {
    width: 50px;
    min-width: 50px;
}
#q5 label.cf-label {
    width: 100px;
}
#q5 input {
    width: 50px;
}
/*Q6 New Revision*/
 #q6 .cf-field {
    width: 50px;
    min-width: 50px;
}
#q6 label.cf-label {
    width: 100px;
}
#q6 input {
    width: 50px;
}
/* Row One In Line Block */
 #q3, #q4, #q5, #q6 {
    display:inline-block;
}
/*Q7 Obsolete/Superseded Parts*/
 #q7 .cf-field {
    width: 350px;
    min-width: 200px;
}
#q7 label.cf-label {
    width: 220px;
}
#q7 input {
    width: 300px;
}
/*Q8 Prints Rescanned*/
 #q8 .cf-field {
    width: 150px;
}
#q8 label.cf-label {
    width: 150px;
}
/* Row Two In Line Block */
 #q7, #q8 {
    display:inline-block
}
/*Q9 Description of Change*/
 #q9 .cf-field {
    width: 700px;
}
#q9 label.cf-label {
    width: 150px;
}
#q9 textarea {
    width: 700px;
}
/*Q10 Quote Updated*/
 #q10 div {
    width: 100px;
}
#q10 label.cf-label {
    width: 125px;
}
/*Q11 Quote Number*/
 #q11 .cf-field {
    width: 300px;
}
#q11 label.cf-label {
    width: 75px;
}
#q11 input {
    width: 100px;
}
/*Row Four In Line Block*/
 #q10, #q11 {
    display:inline-block
}
/*Q12 Quote Effected PM*/
 #q12 .cf-field {
    width: 150px;
}
#q12 label.cf-label {
    width: 175px;
}
#q12 input {
    width: 150px;
}
/*Q13 Quote Effected Open Jobs*/
 #q13 .cf-field {
    width: 150px;
}
#q13 label.cf-label {
    width: 175px;
}
#q13 input {
    width: 150px;
}
/*Row Five In Line Block*/
 #q12, #q13 {
    display:inline-block
}

 Its long and crude, but it organizes the layout in a manner that matches our paper form

 

Currently,

I have a "Quote Updated?" Field (Radio Button) with Yes/No (each with their respective value assigned)

Class = Quote

 

The "Quote#" Field is set with some Javascript (Since i cant use field rules and CSS) to become enabled when the Previous radio button is ticked "Yes". initially this is set to 'hidden' on (Document).ready

Class = QNumber

 

This functions 100% on the initial collection, However, as soon as i click "Add Part" to repeat the collection, The 2nd collection does not start with the "Quote#" Field as disabled, It is not until i click the radio button that this field refreshes (obviously this is due to the javascript)

 

I would like the field to start disabled at the beginning to avoid a "No" result (Field value by default) and a Quote# both happening.

 

Another problem arising is any additional repeats of the collection, result in the the 2nd entry/repeat's "Quote Updated" radio button value to disappear (The buttons both become unchecked)

 

$('cf-collection-block').ready(function () {
    $('.QNumber').addClass('hidden');
    $('.cf-collection-block').on('click', showhide);

    function showhide() {
        $('.cf-collection-block ul').each(function () {

            if ($(this).find('.Quote input:checked').val() == 'Yes') {
                $(this).find('.QNumber').removeClass('hidden');
            } else {
                $(this).find('.QNumber').addClass('hidden');
            }
        });

    }

});

This code was hodge podged together from various places, and the little bit of reading i've been doing.

LF Answers.JPG
LF Answers.JPG (95.08 KB)
0 0

Answer

SELECTED ANSWER
replied on August 15, 2014 Show version history

You can disable the fields, instead of hiding them. Try this:

 

$(document).ready(function () {
  showhide();
    $('.cf-collection-block, .cf-collection-append').on('click', showhide);

    function showhide() {
        $('.cf-collection-block ul').each(function () {
          var quoteNumber = $(this).find('.QNumber input');

            if ($(this).find('.Quote input:checked').val() == 'Yes') {
                quoteNumber.removeAttr('disabled');
            } else {
                quoteNumber.attr('disabled', true);
            }
        });

    }
});

As a note, this code works with input fields. If you want to disable multi-line or drop-down fields, you'll need to adjust the selector in your quoteNumber variable.

1 0

Replies

replied on August 15, 2014 Show version history

Do you actually want to disable/enable the fields, or do you want to show/hide them?

 

Here's your code, slightly modified to work when more collections are added to the form.

 

$(document).ready(function () {
    showhide();
    $('.cf-collection-block, .cf-collection-append').on('click', showhide);

    function showhide() {
        $('.cf-collection-block ul').each(function () {
            var quoteNumber = $(this).find('.QNumber');

            if ($(this).find('.Quote input:checked').val() == 'Yes') {
                quoteNumber.show();
            } else {
                quoteNumber.hide();
            }
        });
    }
});

I'd love to know if you found the Forms documentation and other posts here useful while you were working on this. If there's something you think I should add to the documentation that would make it easier, please let me know.

0 0
replied on August 15, 2014 Show version history

Thank you for the Reply Eric!!

 

Well I'm not sure on the exact terminology, as i've seen in change throughout the topics here on laserfiche answers.. I would like to prevent data from being entered into the field, without jeopardizing the layout. I read that i could start the field with .cf-label {display:none}, but i was unable to toggle that property back on within the script. The layout was also compromised while modifying that property..

 

This "Graying Out"/"Disabling" method i prefer, not only because of the layout maintaining shape, but it also lets data entry users know that there is another field there. 

 

0 0
SELECTED ANSWER
replied on August 15, 2014 Show version history

You can disable the fields, instead of hiding them. Try this:

 

$(document).ready(function () {
  showhide();
    $('.cf-collection-block, .cf-collection-append').on('click', showhide);

    function showhide() {
        $('.cf-collection-block ul').each(function () {
          var quoteNumber = $(this).find('.QNumber input');

            if ($(this).find('.Quote input:checked').val() == 'Yes') {
                quoteNumber.removeAttr('disabled');
            } else {
                quoteNumber.attr('disabled', true);
            }
        });

    }
});

As a note, this code works with input fields. If you want to disable multi-line or drop-down fields, you'll need to adjust the selector in your quoteNumber variable.

1 0
replied on August 15, 2014
I will give that a try on monday, thank you eric.. ill let you know the results
0 0
replied on August 18, 2014

That code worked Flawlessly with regards to the cells.. However, My radio buttons are still setting themselves to blank when i click Next Part..

 

First time through the collection, everything works fine. (Click "Next Part")

Second time, Same as the first.. (Click "Next Part")

The Radio buttons on the second part "Quote Updated" become blank/unchecked..

Any parts added after that, will turn the second entry's Quote Updated Radio buttons to both unchecked

0 0
replied on August 18, 2014

"Next Part" is the label for adding another collection? So, when you add a new collection, the new collection's radio button is not selected? Or is it actually clearing the value from a previous collection?

0 0
replied on August 18, 2014

Its clearing the Value from the Second Entry.. Always and only the second entry, regardless of how many parts i add.

0 0
replied on August 18, 2014

Are you using any JavaScript on the form?
 

0 0
replied on August 18, 2014 Show version history

Only the code listed in this post.. nothing extra, no field rules.. I do have the fields "Default Value" set to "No".. this was configured when the field was added, within the field settings

0 0
replied on August 18, 2014 Show version history

It looks like that's a bug. I've let the developers know and I'll update you when there's a solution. Meanwhile, if you do not specify a default value for the radio button, you should not encounter this issue.

 

Update: This issue is resolved in Forms 9.2.

0 0
replied on August 18, 2014

Thank you again Eric

0 0
replied on August 18, 2014

You're welcome!

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

Sign in to reply to this post.