Usage

With a db table and a petapoco poco in place you'll have a couple of steps to follow. Important: your table must have a primary key column (and your poco must mark it with the PrimaryKeyColumn attribute)

Decorate your class with the UIOMatic attribute

In order for UI-O-Matic to pick up your poco you'll have to mark it with the UIOMatic attribute

[UIOMatic("people","People","Person")]

The UIOMatic attribute has a contructor with 3 parameters

You can also specify additional parameters

Decorate properties with the UIOMaticField attribute

All fields you wish to be editable by UI-O-Matic must be decorated with the UIOMaticField attribute like so.

 [UIOMaticField]

You can also specify additional parameters

Optionally it's also possible to specify a view

[UIOMaticField(View = UIOMatic.Constants.FieldEditors.File)]

There are a couple out of the box views you can use

Besides the out of the box ones you can also use a completely custom one

[UIOMaticField(View = "~/App_Plugins/Example/picker.person.html")]

Validation

UIOMatic will validate using the standard .net data annotation, so you can just decorate your properties with those.

[Required]
public string FirstName { get; set; }

Override the ToString method

UI-O-Matic will call the ToString method when it tries to fetch the tree item names, so make sure to override that one.

public override string ToString()
{
    return FirstName + " " + LastName;
}

Complete example

Here is a complete example that puts the different bits together.

[UIOMatic("people", "People", "Person", FolderIcon = "icon-users", ItemIcon = "icon-user")]
[TableName("People")]
public class Person
{
    [PrimaryKeyColumn(AutoIncrement = true)]
    public int Id { get; set; }

    [Required]
    [UIOMaticField(Name="First name", Description="Enter your firstname")]
    public string FirstName { get; set; }

    [Required]
    [UIOMaticField(Name="Last name", Description="Enter your lastname")]
    public string LastName { get; set; }

    [UIOMaticField(Name = "Picture", Description="Please select a picture",View =  UIOMatic.Constants.FieldEditors.File)]
    public string Picture { get; set; }

    public override string ToString()
    {
        return FirstName + " " + LastName;
    }
}

Result