Developer forum

Forum » CMS - Standard features » Webforms system field values

Webforms system field values

Jens Mouritzen
Jens Mouritzen
Reply

Hi

Is it possible to put system values/data (in this example prices defined in website settings) on form dropdown values, in "Forms For Editors"? 
I would like to put the values (prices from website settings, "image2.png") on a list like the one on "image1.png"

image1.png image2.png

Replies

 
Nicolai Pedersen
Reply

Hi Jens

Yes, in various ways.

First of all the forms has a template option - you can use your own. Form templates can be rendered in ways - one is a loop of fields making the template dynamic, the other is adding each field manually to the template as they are created in the module.

So something like this:

@foreach (LoopItem field in GetLoop("Fields"))
                {
                    int fieldId = field.GetInteger("Field.ID");
                    string fieldHtmlId = field.GetString("Field.HtmlId");
                    string fieldName = field.GetString("Field.Name");
                    string fieldSystemname = field.GetString("Field.SystemName");
                    string fieldControl = field.GetString("Field.Control");
                    string fieldDescription = field.GetString("Field.Description");
                    string fieldType = field.GetString("Field.Type");
                    bool fieldIsButton = field.GetBoolean("Field.IsButton");
                    bool fieldIsOther = field.GetBoolean("Field.IsOther");
                    bool fieldRequired = field.GetBoolean("Field.Required");

                    if (fieldName == "MyDropdown" && fieldType == "Select")
                    {
                        <select id="@fieldHtmlId" name="@fieldSystemname">
                            @foreach (LoopItem option in GetLoop("Options"))
                            {
                                string optionValue = option.GetString("Option.Value");
                                string price = string.Empty;
                                if (optionValue == "Stor pakke")
                                {
                                    Pageview.AreaSettings.GetString("YourItemSystemNameFor_Lille_pakke_pris");
                                }
                                <option value="@optionValue">@option.GetString("Option.Text") @price</option>
                            }
                        </select>
                    }
                    //More logic
                }
 
Nicolai Pedersen
Reply

Or add a bit of javascript to update the select list with prices from the area item getting hold of the values like this:

Pageview.AreaSettings.GetString("YourItemSystemNameFor_Lille_pakke_pris");

 

You must be logged in to post in the forum