Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kerri Mallinson 113 posts 497 karma points
    Apr 27, 2017 @ 17:02
    Kerri Mallinson
    0

    Umbraco Forms FieldType Name or ID

    Hi,

    Does anyone know where I can find the names or Ids of the built in data field types in UF?

    I'm trying to output different things depending on the type of field; I can do this: @if (f.FieldType.Name == "Checkbox") but only because I guessed what the name was

    Thanks Kerri

  • Tim Watts 90 posts 395 karma points
    Apr 28, 2017 @ 09:55
    Tim Watts
    0

    Hi Kerri,

    The Umbraco Forms fields are output using the partial views in Views\Partials\Forms\FieldTypes. These use the guid as the field Id and Name. There is a view for each field type.

    The form itself is rendered via Views\Partials\Forms\Form.cshtml which uses FieldViewResolver.GetFieldView to choose which of the partial views to render.

    Tim

  • Kerri Mallinson 113 posts 497 karma points
    Apr 28, 2017 @ 10:34
    Kerri Mallinson
    0

    Hi Tim,

    Thanks for the reply :)

    This is where I am looking, in the Form.cshtml. I can do this for example; @if (f.FieldType.Name == "Checkbox") { do something }

    What i can't figure out is where i get this list of "Names" from, eg this condition effects the field that uses the partial: FieldType.CheckBox.cshtml, what 'Name' would i use to put a condition on the field that uses: FieldType.DatePicker.cshtml for example?

    Does that make sense?

    Thanks Kerri

  • Tim Watts 90 posts 395 karma points
    Apr 28, 2017 @ 10:59
    Tim Watts
    100

    Kerri,

    The names available are those that you see in the form designer when you choose the answer type, for example:

    • Short answer
    • Title and description
    • Date
    • Checkbox

    Each of these will correspond to one of the FieldType partial views.

    I have done something very similar in my forms. If the field type is a Checkbox then I set an additional class at the outer element.

    Tim

  • Kerri Mallinson 113 posts 497 karma points
    Apr 28, 2017 @ 12:38
    Kerri Mallinson
    0

    Thanks Tim, Easy if you know where to look! :)

Please Sign in or register to post replies

Write your reply to:

Draft