Developer Docs - Mobile Docs - Attribute Value Editor
Inherits from Xamarin.Forms.ContentView
This view takes care of all logic behind deciding which UI to show when editing an attribute value. This is a developer level control. You shouldn't need to use this field unless you are developing a custom block.
Normal usage would be to loop through all the attributes on an entity and build a collection of these views, one for each attribute. All with a unique name that can be used when the data is submitted back to the user to know which attributes to update with what values. As noted below in the examples section, there is a helper method in the MobileHelper class that will do all of this for you.
Note: Only a subset of Rock field types are supported. You can find a list of those here.
Properties
Example
The above example creates a field on the screen that the user can use to enter a date. For normal uses, you would just use a DatePicker view instead. But remember this is intended to provide you with a value in the proper format to be stored in an Attribute Value. A more realistic example (in C#) is below.
var attr = CurrentPerson.Attributes["BaptismDate"];
var xamlFragment = string.Format( @"",
attr.Name.EncodeXml( true ),
attr.IsRequired,
attr.FieldType.Class,
attr.QualifierValues.ToDictionary( a => a.Key, a => a.Value.Value ).ToJson().EncodeXml( true ),
CurrentPerson.GetAttributeValue( attr.Key ).EncodeXml( true ) );
The above code is going to get the attribute definition for the BaptismDate attribute and then build an Attribute Value Editor field that will edit the value. If you were to use this you would also need to include a way to pass whatever value the user entered back to your form with an x:Name attribute or something as well. In fact, we have an entire helper method that will build a form of attributes that you can use. The above could be simplified into:
using Rock.Mobile;
var attributes = CurrentPerson.Attributes.Values.ToList();
var xamlFragment = MobileHelper.GetEditAttributesXaml( CurrentPerson, attributes );
Check out the mobile Group Edit block to see a good example of how to build a form with editable attributes by using the above method.