Search code examples
canvasgallerysharepoint-onlineshow-hidepowerapps

Power Apps Gallery and Showing or Hiding the Submit Button inside a Form on Canvas App


I have a Power Apps Canvas Form where I have inserted several galleries as checkboxes for items that are selected. These are all required fields in the form. I also want the asterisk (STARVISIBLE) to display at the same time the submit BUTTON is greyed out. So, when a user is completing the form, I want the asterisks (STARVISIBLE) to disappear when the selections for that DataCard are valid, and the submit BUTTON to display color when the form is ready to submit.

In the Form, the default StarVisible VISIBLE control = And(Parent.Required, Parent.DisplayMode=DisplayMode.Edit)

The gallery CHECKBOX controls are resolving to a collection OnCheck = Collect(MyProductsCollection, ThisItem) OnUncheck = Remove(MyProductsCollection, ThisItem)

There is also one variable on the CHECKBOX property, Reset = IsReset

The submit BUTTON OnSelect control is set to:

SubmitForm(Form4);
Set(
    IsReset,
    true
);
Set(
    IsReset,
    false
);
Clear(MyProductsCollection);
ResetForm(Form4);
Navigate(
    HOME,
    ScreenTransition.CoverRight
)

How can I get the StarVisible (asterisk) to show when the Submit button is grey and to hide when the submit button is showing because the form is ready to submit?

In the same instance, if I change the original StarVisible's VISIBLE control to And(!Parent.Valid, Parent.DisplayMode=DisplayMode.Edit) the asterisk is hidden immediately and I cannot submit the form.

Can anyone help?


Solution

  • Set StarVisible.Visible to !Form4.Valid, it will disappear when you have satisfied all required fields (= when your form is ready).

    If you have custom logic for the Button's DisplayMode, use SubmitButton.DisplayMode <> DisplayMode.Edit

    Also, it seems you are using redundant code to reset your form. Check if ResetForm() alone achieves the same without using the Reset properties inside the form.