I am builidng a contour form using code first approach (great by the way!) and was wondering how I would go about getting additional settings or parameters into the view for each field? Like addtional CSS styles or anything else I might want to access in the view. I tried AdditionalSettings but that is returning nothing in the view.
I am using it like below in a view - but AdditionalSettings is always returning nothing. I think I must be missing something. Should AdditionalSettings be Key Value Pairs?
foreach (FieldsetViewModel fs in Model.CurrentPage.Fieldsets)
Okay - so how would we go about adding additional settings to a textfield? If for example we wanted to add an additional HTML attribute to each textfield? Would we have to create our own field type/field attribute/field view model so we could pass the class into the view?
Hi Tim, Would it be possible to give an example of how to do this in Forms? I'd like to make a custom field type which displays text on the form but does not submit anything to the entries table. Just can't seem to figure out how to exclude the field from the submission process... Thanks, Steve
Code First - Field Additional Settings
Hey,
I am builidng a contour form using code first approach (great by the way!) and was wondering how I would go about getting additional settings or parameters into the view for each field? Like addtional CSS styles or anything else I might want to access in the view. I tried AdditionalSettings but that is returning nothing in the view.
Any ideas?
Thanks,
Kenny
example:
Comment author was deleted
Take a look at the recaptcha view that has an example :)
Comment author was deleted
So that has the example Model.AdditionalSettings.FirstOrDefault(x => x.Key == "Theme").Value
I am using it like below in a view - but AdditionalSettings is always returning nothing. I think I must be missing something. Should AdditionalSettings be Key Value Pairs?
foreach (FieldsetViewModel fs in Model.CurrentPage.Fieldsets)
{
@foreach (FieldViewModel f in fs.Fields)
{
if (f.AdditionalSettings.Count > 0)
{
//do something
}
}
}
Comment author was deleted
will check captcha code to see how it's handled :)
Comment author was deleted
The fieldtype also needs the extra setting :) maybe that is missing
Comment author was deleted
so in case of the recaptcha one it has a setting
[Setting("Theme", prevalues = "red,white,blackglass,clean,custom", description = "ReCaptcha theme", control = "Umbraco.Forms.Core.FieldSetting.Dropdownlist")] public string Theme { get; set; }
Comment author was deleted
so since you aren't setting the type it's just a textfield and that doesn't have any additional settings
Okay - so how would we go about adding additional settings to a textfield? If for example we wanted to add an additional HTML attribute to each textfield? Would we have to create our own field type/field attribute/field view model so we could pass the class into the view?
Sorry - have been going round in circles!
Comment author was deleted
New fieldtype :) probably inherit from textfield and add the extra setting + make sure to update the guid
Hi Tim,
Would it be possible to give an example of how to do this in Forms? I'd like to make a custom field type which displays text on the form but does not submit anything to the entries table. Just can't seem to figure out how to exclude the field from the submission process...
Thanks, Steve
Thanks for all your help Tim - i think this is what we were after.
Cheers! :)
is working on a reply...