dotnetnuke2sxc

Get field atributes / metadata based on the field name


This is a related issue to 2sxc Get list of fields of an entity

I still have the entity entity "Cars" with two fields "Brand" and "Model".

pic1

Each field has a title, placeholder, notes, dropdown values, etc.

pic2

I need to show a details view for a single car, selected with

var thisCar = AsList(App.Data["Cars"]).Where(e => e.EntityId == 12345).First();

I now need to show some attributes/metadata of each fields. Let's say this:

<div>
    <p>EntityId: @thisCar.EntityId</p>
    <p>(Brand label/name): @thisCar.Brand (placeholder for the Brand field)(dropdown values for the Brand field)</p>
    <p>(Model label/name): @thisCar.Model (placeholder for the Model field)(dropdown values for the Model field)</p>
</div>

In this case, I do not need to loop through all the attributes, but I need to access the field label, default value, placeholder, notes, dropdown values, etc, based on the field name.

How can I achieve this?


Solution

  • This is quite difficult to do, as the internals are not meant to be used for these kinds of scenarios.

    But if you really want to do it, check out https://2sxc.org/dnn-tutorials/en/razor/tut/data-contenttype