I am attempting to use a uComponents Country Picker data type as a Prevaliue Source on a dropdown on a form and it's not working. Looking for a little help and/or advice.
That pretty much says it all. For some reason Contour is only importing the following prevalues:
DropDownList
Empty -- I assume this is the un-selected value, like "Please Select"
This uComponent works absolutely fine on a Document Type but not in Contour. Anyone heard of or know anything about this? Any luck using datatypes as prevalues? The only examples I can find are using a SQL DB.
Hmmm..... shame. I'd love to use the text file method but I don't know where to place the files (the post doesn't say), nor am I in a dev environment for compiling anything. Thanks.
Excellent. Ok so we're talking about UmbracoContour_3.0 WIP.zip or UmbracoContour_3.0 WIP_update.zip? And should I do this from "Install local package" using the wizard? Sorry to keep harping it's just that I am in the advanced stages of a project before prod deploy so I can't afford for anything to go south right now. Version I have currently installed is 1.1.13, latest stable from CodePlex.
And should I do this from "Install local package" using the wizard? Sorry to keep harping it's just that I am in the advanced stages of a project before prod deploy so I can't afford for anything to go south right now.
Version I have currently installed is 1.1.13, latest stable from CodePlex.
I unpacked 3.0 WIP update into my root. You didn't say whether to use the update or the full but since I already had 1.1.13 instaleld I figured this would be an update. I have none of my preexisting forms and get this error on every page in Contour:
Exception information:
Exception type: ArgumentException
Exception message: Must specify valid information for parsing in the string.
at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
at Umbraco.Forms.Core.FormSettings..ctor()
at Umbraco.Forms.Core.Form.CreateFromDataReader(IRecordsReader reader)
at Umbraco.Forms.Data.Storage.FormStorage...()
at umbraco.cms.businesslogic.cache.Cache.GetCacheItem[TT](String cacheKey, Object syncLock, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem)
at Umbraco.Forms.Data.Storage.FormStorage.GetAllForms(Boolean archived)
at Umbraco.Forms.UI.Dashboard.FormsDashboard.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)å
The only thing the upgrade instructions say is to do what I did -- extract into root. It replaced several files in bin, umbraco, umbraco_client, and usercontrols. Everything else seems to be working fine, but the upgrade has broken Contour. What do you recommend I do? I am trying to go from 1.1.13 to 3.0 WIP. This time I'm afraid you can't say follow the instructions because I already did that ;) By the way, right after the "FormStorage" line, there is actually a MUSIC note symbol in the error, which won't paste into preformatted view of course. What's going on?
Basically I just need to know what I should do at this point -- uninstall using the wizard and then reinstalling 1.1.13 again or 3.0 WIP fresh, or trying to replace my old files. Or, ideally, get to the bottom of the error.
I have managed to bring back both the back and front end. It was something stupid -- when I copied the old files back in from git Windows had encrypted them so they couldn't be read. Sorry for the alarm! Back to business -- the original error after the 3.0 WIP update -- the string parsing error -- as I said, I extracted the update file into the root and this is the error I get everywhere in Contour afterwards. How to upgrade???
Was this issue resolved? I just had the same problem when upgrading a production site. For me the issue was caused because the [site root]\umbraco\plugins\umbracoContour\UmbracoContour.config file had not been transfered.
Note to devs: Contour should either (a) not throw an exception when this file is not present or (b) throw an exception stating the file is missing
Agreed..... This issue was indeed resolved, yes. It was just that I was trying to get Contour to do something it couldn't do with respect to how the prevalues are stored by uCompnents. I ended up using the text file method along with a very simple custom PreValueType control. Thanks for checking in with me.
@Martin, if you upgrade the code first assembly to 3.0.2 WIP (http://nightly.umbraco.org/Umbraco%20Contour/) you should be able to setup a prevalue source on a field like this:
[Field("Leave a comment", "Your comment",
Type = typeof(Umbraco.Forms.Core.Providers.FieldTypes.DropDownList),
PrevalueSource = "Countries")]
publicstring Country { get; set; }
Assuming you have a prevalue source with the name Countries
Will also make it possible to create prevalue sources code first soon :)
That's more than awesome! Thanks so much for sorting this.
As you so on it at the moment I have another question for you...
I'm trying to use the contour contrib (Captcha). You've answered some questions for me on this subject before.
I've noticed that if I override the Validate() method and insert a form as a usercontrol, the method refuses to fire. If I insert it as a razor control the Validate() method works but I then have to supply a .cshtml file for the captcha in Umbraco\plugins\umbracoContour\Views - It looks to be a completely user controllable rendering of the field. The problem at this point is that FieldViewModel doesnt seem to expose the AdditionalSettings attribute so that I can extract the public key for the Captcha. Well it doesnt seem to expose settings at all, apart from the standard ones.
Is Validate() for the usercontrol fixed in 3.0.2 or is there a way I can get this working in the partial View?
@Martin the validate method only works on the razor macro ,the usercontrol one doesn't support this
What's also good to note is that the razor macro has a default antispam (using honeypot technique), not sure how to use the recaptcha in mvc mode but will see if I can find some details
Ok thats fine I can accept that it wont work as a user control.
The problem I have is that the re-captcha has a bunch of settings which are not part of formbase. In the attributes section of a codefirst form is an AdditionalSettings[] array which I suppose is for getting access to anything beyond the core. But i've not tested that yet.
For the partial view it's a bit different because you have to use the FieldViewModel class to get access to much the same properties as you would in a codefirst form. Unfortunately there's no "settings" or "additionalsettings" property in this class! Very frustrating!
If I export the form containing the Captcha here's what the settings section looks like...
I’ve hit a stumbling block creating a code first form with the countries custom prevalue source.
I created my drop down list and also added your code first suggestion to get the countries list to automatically appear. But when I submit the form I get this really odd error.
"Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."
If I remove the dropdownlist the form works and submits ok.
Hmm, sorry to keep bugging you but it's not fixed yet!
There's a number of scenarios i've noticed which are failing, first one is by simply decorating the form with the following attribute...
1. Prevalues = new string[] {"one", "two", "three"}
If not set to Mandatory (blank can be selected). It errors as Unrecognized Guid format. on blank, and Object of type 'System.Collections.Generic.List`1[System.String]' cannot be converted to type 'System.String'. If I select "one" "two" or "three" upon Submit()
2. (Countries) Custom prevalue datasource
I've noticed your code suggests using the following for the key/value pairs.
foreach (var c in countries)
{
PreValue pv = new PreValue();
pv.Id = c.Key;
pv.Value = c.Value;
Now a prevalue id is meant to be a GUID from what I can tell, rather than the country code (gb, us, etc). So if I change it to....
foreach (var c in countries)
{
PreValue pv = new PreValue();
pv.Id = Guid.NewGuid();
pv.Value = c.Value;
I get the same error as in item 1...Object of type 'System.Collections.Generic.List`1[System.String]' cannot be converted to type 'System.String'. If I leave you code as you originally suggested on your blog I continue to get the incorrect guid error upon Submit().
Ok if you upgrade the umbraco.forms.mvc assembly to 3.0.4 WIP you should have a new property on the viewmodel called additional settings that will be populated with any extra settings
I've tested the prevalues and prevaluesource and all is working as expected. Congrats to you on your efforts, I really cannot thank you enough!
Code first was a great idea!
I'll test out the AdditionalSettings in the FieldViewModel as soon as possible.
I only wish you worked on Courier 2.7.x, I still have an outstanding issue with media items transferring but not getting added to the media section if embedded as a link in the TinyMCE. I've not had a single acknowledgement of the issue let alone a resolution.
If we ever meet at an Umbraco convention, remind me I owe you a drink at the bar!
I have downloaded the contour.codefirstexample files and have updated the sample registration form to include a new field (checkboxlist) which populates its options from a prevalue source called "Org Type". This prevalue source links to a custom data type called "Org Type" which again is a checkboxlist.
When I run a the form to test it, I get the following error Object of type 'System.Collections.Generic.List`1[System.String]' cannot be converted to type 'System.String'.
I am not sure what to try next. I have seen this issue listed earlier in the post but version 3.0.4 on the forms.MVC assembly was supposed to correct this yet I am experiencing the same error on version 3.0.14!
If I remove this checkboxlist field the error goes away and I can perform the same action on a dropdownlist with a prevalue without any issues at all so I feel it has something to do with checkboxlist datatype or my custom one "Org Type" perhaps?!
My custom field "Org Type" is set to datatype Nvarchar if that matters although I have tried changing to an integer but same error.
The field loads the values fine when the form is rendered but attempting to save those ticked values back to the "Org Type" field in my member profile fails.
I have found another post from Tim which explained that I needed to to change the field type from a public string to a list<string> since the data is needed in string format. So now my field looks like below and no error.
Type = typeof(Umbraco.Forms.Core.Providers.FieldTypes.CheckBoxList),
Mandatory = true,
PrevalueSource = "Org Type")]
public ListOrganisationType { get; set; }
However! Although the entry is passed fine through to Contour, the values in my member profile are not updated and still show as unticked?? Again this works for other data types so I think my code is right to update a custom property. Here it is below but Im stumped again now!
I have updated my code to public List OrganisationType { get; set; } but I get an error now when building assembly saying:
Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments
Orginally the code was public List<string> OrganisationType { get; set; } but as I said, the form works fine without error but then doesnt actually update the member property type to match.
Country Picker
Hi,
I am attempting to use a uComponents Country Picker data type as a Prevaliue Source on a dropdown on a form and it's not working. Looking for a little help and/or advice.
That pretty much says it all. For some reason Contour is only importing the following prevalues:
Thanks,
Garrett
Comment author was deleted
Hey Garret, currently this isn't supported since the country picker stores it's values in a different way so it won't work
The fastest option would be to use the get values from textfile type as shown here: http://www.nibble.be/?p=86
Hmmm..... shame. I'd love to use the text file method but I don't know where to place the files (the post doesn't say), nor am I in a dev environment for compiling anything. Thanks.
//Garrett
Comment author was deleted
You can upgrade to 3.0 WIP that includes the prevalue source type out of the box :)
http://nightly.umbraco.org/Umbraco%20Contour/
Upgrade instructions can be found on the Contour project page
http://our.umbraco.org/projects/umbraco-pro/contour
I like this option Tim -- will I lose any preexisting forms when upgrading?
Thanks,
Garrett
Comment author was deleted
Nope all your forms will still be present :)
Excellent. Ok so we're talking about UmbracoContour_3.0 WIP.zip or UmbracoContour_3.0 WIP_update.zip? And should I do this from "Install local package" using the wizard? Sorry to keep harping it's just that I am in the advanced stages of a project before prod deploy so I can't afford for anything to go south right now. Version I have currently installed is 1.1.13, latest stable from CodePlex.
Thanks again,
Garrett
Excellent. Ok so we're talking about:
UmbracoContour_3.0 WIP.zip
--or--
UmbracoContour_3.0 WIP_update.zip
?
From:
http://nightly.umbraco.org/Umbraco%20Contour/3.0%20WIP/
?
And should I do this from "Install local package" using the wizard? Sorry to keep harping it's just that I am in the advanced stages of a project before prod deploy so I can't afford for anything to go south right now.
Version I have currently installed is 1.1.13, latest stable from CodePlex.
Thanks again,
Garrett
Comment author was deleted
It's not a package you can install please read the upgrade instructions on the project page basicly it's a xcopy you need to do :)
Hi Tim,
I unpacked 3.0 WIP update into my root. You didn't say whether to use the update or the full but since I already had 1.1.13 instaleld I figured this would be an update. I have none of my preexisting forms and get this error on every page in Contour:
The only thing the upgrade instructions say is to do what I did -- extract into root. It replaced several files in bin, umbraco, umbraco_client, and usercontrols. Everything else seems to be working fine, but the upgrade has broken Contour. What do you recommend I do? I am trying to go from 1.1.13 to 3.0 WIP. This time I'm afraid you can't say follow the instructions because I already did that ;) By the way, right after the "FormStorage" line, there is actually a MUSIC note symbol in the error, which won't paste into preformatted view of course. What's going on?
Thanks,
Garrett
Basically I just need to know what I should do at this point -- uninstall using the wizard and then reinstalling 1.1.13 again or 3.0 WIP fresh, or trying to replace my old files. Or, ideally, get to the bottom of the error.
Thanks again,
Garrett
I elected to replace the old files -- and now I am getting this error on both front and back end:
[FileLoadException: Could not load file or assembly 'Umbraco.Forms.Core' or one of its dependencies. Access is denied.]
That file is present. All the persmissions look fine. Please help, everything is down now.
//Garrett
I have managed to bring back both the back and front end. It was something stupid -- when I copied the old files back in from git Windows had encrypted them so they couldn't be read. Sorry for the alarm! Back to business -- the original error after the 3.0 WIP update -- the string parsing error -- as I said, I extracted the update file into the root and this is the error I get everywhere in Contour afterwards. How to upgrade???
Thanks,
Garrett
Garret,
Was this issue resolved? I just had the same problem when upgrading a production site. For me the issue was caused because the [site root]\umbraco\plugins\umbracoContour\UmbracoContour.config file had not been transfered.
Note to devs: Contour should either (a) not throw an exception when this file is not present or (b) throw an exception stating the file is missing
Agreed..... This issue was indeed resolved, yes. It was just that I was trying to get Contour to do something it couldn't do with respect to how the prevalues are stored by uCompnents. I ended up using the text file method along with a very simple custom PreValueType control. Thanks for checking in with me.
//Garrett
Hi Tim
How do I use the countries Prevalue source type in a code first form?
Regards
Martin
Comment author was deleted
Hi Martin,
Currently that isn't supported but I'm looking into it, will be part of the next maintenance release...
Comment author was deleted
@Martin, if you upgrade the code first assembly to 3.0.2 WIP (http://nightly.umbraco.org/Umbraco%20Contour/) you should be able to setup a prevalue source on a field like this:
Assuming you have a prevalue source with the name Countries
Will also make it possible to create prevalue sources code first soon :)
Hi Tim
That's more than awesome! Thanks so much for sorting this.
As you so on it at the moment I have another question for you...
I'm trying to use the contour contrib (Captcha). You've answered some questions for me on this subject before.
I've noticed that if I override the Validate() method and insert a form as a usercontrol, the method refuses to fire. If I insert it as a razor control the Validate() method works but I then have to supply a .cshtml file for the captcha in Umbraco\plugins\umbracoContour\Views - It looks to be a completely user controllable rendering of the field. The problem at this point is that FieldViewModel doesnt seem to expose the AdditionalSettings attribute so that I can extract the public key for the Captcha. Well it doesnt seem to expose settings at all, apart from the standard ones.
Is Validate() for the usercontrol fixed in 3.0.2 or is there a way I can get this working in the partial View?
Thanks again
Martin
Comment author was deleted
Creating prevalue sources code first is now also possible with v3.0.2 WIP
Hi Tim
Thanks thats really useful to note, any ideas on my captcha questions?
Martin.
Comment author was deleted
@Martin the validate method only works on the razor macro ,the usercontrol one doesn't support this
What's also good to note is that the razor macro has a default antispam (using honeypot technique), not sure how to use the recaptcha in mvc mode but will see if I can find some details
Hi Tim
Thanks again, for being so prompt about this...
Ok thats fine I can accept that it wont work as a user control.
The problem I have is that the re-captcha has a bunch of settings which are not part of formbase. In the attributes section of a codefirst form is an AdditionalSettings[] array which I suppose is for getting access to anything beyond the core. But i've not tested that yet.
For the partial view it's a bit different because you have to use the FieldViewModel class to get access to much the same properties as you would in a codefirst form. Unfortunately there's no "settings" or "additionalsettings" property in this class! Very frustrating!
If I export the form containing the Captcha here's what the settings section looks like...
Hi Tim
Digging through the libraries I guess i'm asking for a property insde FieldViewModel that inherits from...
Umbraco.Forms.Core.FieldSetting
But works for custom fields as well as the standard core items.
Bearing in mind that Captcha settings are key/value pairs too!
Thanks
Martin
Hi Tim
Sorry another dig I think it's actually
Umbraco.Forms.Core.Field.Settings
I’ve hit a stumbling block creating a code first form with the countries custom prevalue source.
I created my drop down list and also added your code first suggestion to get the countries list to automatically appear. But when I submit the form I get this really odd error.
"Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."
If I remove the dropdownlist the form works and submits ok.
What have I done wrong?
Martin.
Comment author was deleted
@Martin will give it a go and see if I can reproduce
Comment author was deleted
Ok can confirm the issue, looking into it now
Comment author was deleted
Found and fixed (http://issues.umbraco.org/issue/CON-185), upgrading the codefirst assembly to 3.0.3 WIP should fix it http://nightly.umbraco.org/Umbraco%20Contour/
Tim
You are a Scholar and a Gentleman! Thank you so much for this fix.
Did you get a chance to look at why settings arent exposed in the contour MVC FieldViewModel for the Captcha?
Many thanks again.
M.
Comment author was deleted
Sorry didn't have the complete fix but should be working now if you update the code first assembly to 3.0.4 WIP http://nightly.umbraco.org/Umbraco%20Contour/
No need to change the countries prevalue source, prevalue id can be the country code
Thanks for the help testing this :)
Comment author was deleted
Looking at exposing the extra settings in the view now :)
Comment author was deleted
Ok if you upgrade the umbraco.forms.mvc assembly to 3.0.4 WIP you should have a new property on the viewmodel called additional settings that will be populated with any extra settings
Hi Tim
I've tested the prevalues and prevaluesource and all is working as expected. Congrats to you on your efforts, I really cannot thank you enough!
Code first was a great idea!
I'll test out the AdditionalSettings in the FieldViewModel as soon as possible.
I only wish you worked on Courier 2.7.x, I still have an outstanding issue with media items transferring but not getting added to the media section if embedded as a link in the TinyMCE. I've not had a single acknowledgement of the issue let alone a resolution.
If we ever meet at an Umbraco convention, remind me I owe you a drink at the bar!
Many thanks again
Martin.
I am running umbraco 4.11.10 with contour 3.0.14.
I have downloaded the contour.codefirstexample files and have updated the sample registration form to include a new field (checkboxlist) which populates its options from a prevalue source called "Org Type". This prevalue source links to a custom data type called "Org Type" which again is a checkboxlist.
When I run a the form to test it, I get the following error Object of type 'System.Collections.Generic.List`1[System.String]' cannot be converted to type 'System.String'.
I am not sure what to try next. I have seen this issue listed earlier in the post but version 3.0.4 on the forms.MVC assembly was supposed to correct this yet I am experiencing the same error on version 3.0.14!
If I remove this checkboxlist field the error goes away and I can perform the same action on a dropdownlist with a prevalue without any issues at all so I feel it has something to do with checkboxlist datatype or my custom one "Org Type" perhaps?!
My custom field "Org Type" is set to datatype Nvarchar if that matters although I have tried changing to an integer but same error.
The field loads the values fine when the form is rendered but attempting to save those ticked values back to the "Org Type" field in my member profile fails.
Here is the code for the field:
[Field(FormPages.Registration, FormFieldsets.Details,
Type = typeof(Umbraco.Forms.Core.Providers.FieldTypes.CheckBoxList),
Mandatory = true,
PrevalueSource = "Org Type")]
public string OrganisationType { get; set; }
Any help would be much appreciated.
thanks
Craig.
I have found another post from Tim which explained that I needed to to change the field type from a public string to a list<string> since the data is needed in string format. So now my field looks like below and no error.
[Field(FormPages.Registration, FormFieldsets.Details,
Type = typeof(Umbraco.Forms.Core.Providers.FieldTypes.CheckBoxList),
Mandatory = true,
PrevalueSource = "Org Type")]
public ListOrganisationType { get; set; }
However! Although the entry is passed fine through to Contour, the values in my member profile are not updated and still show as unticked?? Again this works for other data types so I think my code is right to update a custom property. Here it is below but Im stumped again now!
member.getProperty("orgType").Value = OrganisationType;
Comment author was deleted
Hi Craig,
Just change your property to
public List
That should work
Hi Tim,
I have updated my code to public List OrganisationType { get; set; } but I get an error now when building assembly saying:
Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments
Orginally the code was public List<string> OrganisationType { get; set; } but as I said, the form works fine without error but then doesnt actually update the member property type to match.
Sorry if I am misunderstanding your instruction.
cheers
Craig.
Comment author was deleted
I'll give it a try and report back in a min
Comment author was deleted
Just tested with latest Contour and it works fine
My form looks like
[Form("Test", ShowValidationSummary = true, MessageOnSubmit = "TEST!")] public class MyForm: FormBase { [Field("Test", "Test", Mandatory = true)] public string Name { get; set; }
and don't get any errors, property is being filled properly
But the issue is that the member property is probably expecting different data so you'll need to see how it saves the values and replicate this ...
Hi Tim,
I have created a specifc post for this so will reply via http://our.umbraco.org/forum/umbraco-pro/contour/44128-Saving-checkboxlist-values-to-custom-datatype-in-umbraco?p=0#comment159599 instead.
cheers
Craig.
is working on a reply...