Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Show button based on instance count

Avatar

Level 3

Hi all,

I have a repeatable subform that has a zero instance count (starts at zero and can be removed completely) and I have two buttons, one to add instances and one to remove instances. I would like to only show the Remove Instance button when the count is greater than zero (this way the user only sees an Add button when there nothing there, and by adding the 1st instance of the field they will get the remove button which will hide again when the instance count is down to zero).

Is there a way to do this?

1 Reply

Avatar

Level 10

You should have 2 events to help you doing this.

in the click event of the remove button you should have something like this

And you should have an initialize event for the subform