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

Question

Question

Forms - Collection Field - read-only but still able to delete?

asked on March 21, 2017

Greetings!

Working on a form which needs sort of a running event log.

I made a collection of Date/Time, Event Description, and file upload.

This seems to work great - you can add events as they happen and it keeps the running list.

The problem is with the checkbox on each field in that collection - "Previous data or new lookup data will be read-only, but the user-added sets will be editable."

In my testing, this works well.  Except...  I can delete these entries.

Is this intended?  Any way to not allow the deletion of entries, just the add of new ones?

 

Thanks in advance!

Mike

0 0

Replies

replied on March 22, 2017 Show version history

You can hide the delete buttons via code.

Adding this to your CSS script will always hide the delete button (just change collectionCSSClassName to the actual CSS Class Name of your collection): 

.collectionCSSClassName .cf-collection-delete {display : none!important;} 

 

Hiding it on just the read-only fields is a little trickier, but still very doable.

One way to do it is like this (this assumes that your Event Description field is a Single Line field - just change eventDescription to the actual CSS Class Name of the Event Description field in your collection).

Here's the CSS code: 

.hiddenField {display : none!important;} 

 

And here's the Javascript code: 

$(document).on("onloadlookupfinished", function () {
    $('.eventDescription input').each(function() { 
      if($(this).attr('readonly') == 'readonly') { 
        $(this).closest('ul').parent().find('.cf-collection-delete').addClass('hiddenField');
      }
    }); 
}); 

 

When the form has finished loading any lookups it cycles through all of the Event Description fields and if it is disabled, it hides the delete button for that collection row.

If your collection is pre-populated by a different task rather than by lookups, you should be able to swap out the first line of the Javascript with this instead: 

$(document).ready(function () {

 

Good luck!

1 0
replied on June 30
.deleteHide .cf-collection-delete {display : none!important;}
.AddHide .cf-collection-append {display : none!important;}

Based off the CSS Matt gave, I was able to get the Delete 'x' and 'Add' button to hide.

 

Thanks Matt.

0 0
replied on March 24, 2017 Show version history

If you want to not allow delete previous added rows, then you need to have two forms which using same variables to pass the value: add the collection in the first form, then drag the collection variable to add on the second form.

 On the second form, select "Append rows to the rows populated by data source or variable" for the collection", this will make the rows added in first form not able to be deleted on the second form.

1 0
replied on June 12, 2019

Hello! 

I have followed the logic above to hide the delete "X" for fields that are read only. After using the option under the collection variable "Previous data or new lookup data will be read-only, but user-added sets will be editable" 

This works that the "X" is hidden

however when you add a new field into the collection the "X" button reappears for all fields including the read only ones and they can be deleted.

Any suggestions?

Thanks

Mark

replied on May 9, 2024

Might there be a way to accomplish the same thing within Designer Mode?  I know JavaScript code needs to be called in a completely separate way compared to Classic Mode, but I don't know enough to know what pieces to convert to make them work within Designer.

Thanks for anyone that can assist, or alternately please let me know if I should do up a separate post for this!

Thanks in advance...

Marty Gaffney
Town of Okotoks

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

Sign in to reply to this post.