Glass Mapper – Edit Frame for all fields dynamically

Today I created a rendering component which has around 10 fields but the whole component is not editable in Experience Editor. I decided to use Edit Frame from Glass Mapper. The BeginEditFrame wants all the editable fields as a parameter. But for around 10 fields not that comfortable.

The following code snippet creates an Edit Frame only with 1 field.

Let’s implement a method which gets all the fields from your model.

This method gets the model property names with some reflection magic and creates the lambda expressions dynamically.

You can see that the method has a limitation to allows only IGlassBase interfaces. It is needed to make it more safe as this interface contains all the base properties for a Sitecore item.

Let’s use this util method in our view.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s