cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sandipjnj
New Member

Can i insert a edit form into a Gallery?

Hi,

I am new to Power App. I want to insert a edit form into a gallery. Is it possible to do? please give me the suggestion.

1 ACCEPTED SOLUTION

Accepted Solutions
RusselThomas
Microsoft
Microsoft

Hi @sandipjnj ,

Some built-in components are top-tier in terms of their scope - meaning they can be children of a screen, but not children of other components that impact their scope. 

For this reason, you cannot insert an Edit form into a Gallery.

 

If you deconstruct a Form however, you might notice that Forms contain cards that represent each column of data in a source.  The form uses the information provided by the datasource to determine what kind of input controls to use for each card - so a Text column will get a Text Input control, a Date column a datepicker control and so forth.

The point is, cards in forms are made up of standard controls - you can 'build' your own forms by using input controls and sending data back to the source using the Patch() function.  It's usually easier to use Forms and the SubmitForm() function, but sometimes there are good reasons to build your own - but then you have to manually create the user experience (like resetting fields, getting lastsubmit data etc.)

 

As such, there are a couple of ways you can achieve the same effect as adding a form to your gallery.  You can for example place input controls inside your gallery and provide a button for each 'row' to submit the edited data.

You can also place input controls inside your gallery, but use them to populate a hidden form outside your gallery to take advantage.  It really depends on the user experience you're trying to create and whether you need to leverage features of forms or not.


let's assume you have a datasource with a Title column which is just a single line of Text.

Try this as a short example;

Add a gallery, connect it to a datasource.  Call your gallery myGallery.

Edit the first row of the gallery, insert a Text Input control and name it txtInputTitle

Set its Default: property to ThisItem.Title

*optional - Set its Visible: property to ThisItem.IsSelected

Add a button to your gallery row (you can add it to the screen as well, but then the scope context of the OnSelect formula changes)

Set your button's OnSelect: property to 

Patch(yourdatasource, ThisItem, {Title: txInputTitle.Text})

 *optional - Set its Visible: property to ThisItem.IsSelected

 

Similar to the above you can, instead of using the button with the Patch() statement, add a form to your page and configure the forms cards to get their Update: data from the gallery's input controls instead of their own.

Try this instead of adding the patch button above;

Add a form, call it galleryForm

Connect it to your datasource, set it's Item: property to myGallery.Selected

Unlock the Form card that shows the Title text input.  

Set the card's Update: property to txtInputTitle.Text

Add a button to your page somewhere and set it's OnSelect: property to SubmitForm(galleryForm)

 

That should be enough to illustrate - you can hide the form once you're happy it's working so the user won't see it and can't interact with it - but it'll carry on working while hidden.

 

Hope this helps,

RT

 

View solution in original post

2 REPLIES 2
rubin_boer
Super User
Super User

hi @sandipjnj can you elaborate on you trying to achieve, adding an edit form to a gallery can be a problematic thing and it is not possible now. 

RusselThomas
Microsoft
Microsoft

Hi @sandipjnj ,

Some built-in components are top-tier in terms of their scope - meaning they can be children of a screen, but not children of other components that impact their scope. 

For this reason, you cannot insert an Edit form into a Gallery.

 

If you deconstruct a Form however, you might notice that Forms contain cards that represent each column of data in a source.  The form uses the information provided by the datasource to determine what kind of input controls to use for each card - so a Text column will get a Text Input control, a Date column a datepicker control and so forth.

The point is, cards in forms are made up of standard controls - you can 'build' your own forms by using input controls and sending data back to the source using the Patch() function.  It's usually easier to use Forms and the SubmitForm() function, but sometimes there are good reasons to build your own - but then you have to manually create the user experience (like resetting fields, getting lastsubmit data etc.)

 

As such, there are a couple of ways you can achieve the same effect as adding a form to your gallery.  You can for example place input controls inside your gallery and provide a button for each 'row' to submit the edited data.

You can also place input controls inside your gallery, but use them to populate a hidden form outside your gallery to take advantage.  It really depends on the user experience you're trying to create and whether you need to leverage features of forms or not.


let's assume you have a datasource with a Title column which is just a single line of Text.

Try this as a short example;

Add a gallery, connect it to a datasource.  Call your gallery myGallery.

Edit the first row of the gallery, insert a Text Input control and name it txtInputTitle

Set its Default: property to ThisItem.Title

*optional - Set its Visible: property to ThisItem.IsSelected

Add a button to your gallery row (you can add it to the screen as well, but then the scope context of the OnSelect formula changes)

Set your button's OnSelect: property to 

Patch(yourdatasource, ThisItem, {Title: txInputTitle.Text})

 *optional - Set its Visible: property to ThisItem.IsSelected

 

Similar to the above you can, instead of using the button with the Patch() statement, add a form to your page and configure the forms cards to get their Update: data from the gallery's input controls instead of their own.

Try this instead of adding the patch button above;

Add a form, call it galleryForm

Connect it to your datasource, set it's Item: property to myGallery.Selected

Unlock the Form card that shows the Title text input.  

Set the card's Update: property to txtInputTitle.Text

Add a button to your page somewhere and set it's OnSelect: property to SubmitForm(galleryForm)

 

That should be enough to illustrate - you can hide the form once you're happy it's working so the user won't see it and can't interact with it - but it'll carry on working while hidden.

 

Hope this helps,

RT

 

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (27,345)