Checkbox list DefaultValue only takes first value instead of all checked ones
I have a create-form with a checkbox list that takes PreValues from a checkbox list data type. When the form is submitted, a WorkFlow also saves the form as a node (many thanks to Tim and PublishFormAsPage)
Then I created an edit-form which takes DefaultValues not from the record, but from the currentNode, the node containing the edit-form. However, the checkbox list's DefaultValue only takes first value instead of all checked ones.
Is there a way to extend the existing checkbox list FieldType such that it parses multiple values?
Umbraco 4.7.1, Contour 1.1.2, custom workflows (PublishFormAsPage, UpdateFormAsPage) and custom FieldTypes (Label.cs from Contour.Contrib in App_Code folder)
Thank you for pointing me in the right direction. I had not seen the sourcecode for the providers yet. Only two weeks ago I started to learn C#, so I am still somewhat unfamiliar with the source code.
However, it seems that only the value of the first checked checkbox is saved on the node, using Tim's PublishFormAsPage WorkFlow as well as the built-in 'Save as umbraco document' WorkFlow.
Is it so that the values of a checkbox list are stored as a strings of comma separated values in dbo.UFRecordFields[DataTypes]? What if the DataType on the node is not a textstring, but the very same checkbox list as used as a PreValue Source in Contour?
P.S. it turns out Contour 1.1.12 is in use, not 1.1.2.
I downloaded the source code and I managed to get it to work. Here is part of my solution:
public override System.Web.UI.WebControls.WebControl Editor { get { cbl = new Umbraco.Forms.Core.Controls.ValidateableCheckBoxList(); cbl.CssClass = "checkboxlist"; cbl.RepeatLayout = System.Web.UI.WebControls.RepeatLayout.Flow;
if (this.AssociatedField.PreValueSource != null) { foreach (var prevalue in this.AssociatedField.PreValueSource.Type.GetPreValues(this.AssociatedField)) { String value = Data.DictionaryHelper.GetText(prevalue.Value).Trim();
System.Web.UI.WebControls.ListItem item = new System.Web.UI.WebControls.ListItem(value, prevalue.Id.ToString());
if (String.IsNullOrEmpty(DefaultValue)) { // no DefaultValue // check both keys and values if (_value.Contains(value) || _value.Contains(prevalue.Id.ToString())) { item.Selected = true; } } else { // DefaultValue // loop through the stored values of a comma separated string foreach (String val in ParseTokens(DefaultValue).Split(',')) { // check both keys and values if (val.Contains(value) || val.Contains(prevalue.Id.ToString())) { item.Selected = true; } } } cbl.Items.Add(item); } } return cbl; } set { base.Editor = value; } }
It has room for improvement, e.g. when each checkbox is checked the value is compared to all stored values in a comma separated string.
Checkbox list DefaultValue only takes first value instead of all checked ones
I have a create-form with a checkbox list that takes PreValues from a checkbox list data type. When the form is submitted, a WorkFlow also saves the form as a node (many thanks to Tim and PublishFormAsPage)
Then I created an edit-form which takes DefaultValues not from the record, but from the currentNode, the node containing the edit-form. However, the checkbox list's DefaultValue only takes first value instead of all checked ones.
Is there a way to extend the existing checkbox list FieldType such that it parses multiple values?
Umbraco 4.7.1, Contour 1.1.2, custom workflows (PublishFormAsPage, UpdateFormAsPage) and custom FieldTypes (Label.cs from Contour.Contrib in App_Code folder)
Cheers,
León
Comment author was deleted
Well you could download the sourcecode for the providers and perform the update you want, it's available on the contour project page
Tim,
Thank you for pointing me in the right direction. I had not seen the sourcecode for the providers yet. Only two weeks ago I started to learn C#, so I am still somewhat unfamiliar with the source code.
However, it seems that only the value of the first checked checkbox is saved on the node, using Tim's PublishFormAsPage WorkFlow as well as the built-in 'Save as umbraco document' WorkFlow.
Is it so that the values of a checkbox list are stored as a strings of comma separated values in dbo.UFRecordFields[DataTypes]? What if the DataType on the node is not a textstring, but the very same checkbox list as used as a PreValue Source in Contour?
P.S. it turns out Contour 1.1.12 is in use, not 1.1.2.
Tim,
I downloaded the source code and I managed to get it to work. Here is part of my solution:
It has room for improvement, e.g. when each checkbox is checked the value is compared to all stored values in a comma separated string.
Cheers,
León
is working on a reply...