Contour code first and Conditional Logic
Another code first example, setting up field conditions when designing your form in visual studio.
There are 3 properties on the Field attribute that need to be used (EnableCondition, ConditionActionType and ConditionLogicType) then for setting up 1 or multiple rules you’ll need to decorate the property with a FieldConditionRule attribute providing it the caption of the field, the rule operator and the value.
[Field("Leave a comment", "Your comment",
Mandatory = true)]
public string Name { get; set; }
[Field("Leave a comment", "Your comment",
EnableCondition = true,
ConditionActionType = FieldConditionActionType.Show,
ConditionLogicType = FieldConditionLogicType.Any)]
[FieldConditionRule("Name",FieldConditionRuleOperator.Is, "Test")]
public string Hidden { get; set; }
In this case the field with caption hidden will only be shown if the value of the field with caption Name is test

Thanks for this post. it is good sharing
Hi
How would you go about adding conditional logic to enable and disable the submit button.
Lets say on Accepting Terms and conditions checkbox to enable the submit button.
Thanks
Hi Tim,
I’m experimenting with the conditional logic thingy. Great that its available.
Only it doesnt seem to work. Do I need to activate some kind of Javascript plugin or something?
I’ve set the rules, but on the frontend it just shows all fields whatever I do.
(am still running in trial mode, maybe thats the issue?
hope to hear from you soon.
Martin
I’m also experiencing the same issue as you Martin. Allows me to insert the logic but the form seems to ignore it and shows every field.
I’m using Contour 3.0.11 and Umbraco 4.11.8
@Martin and Dan, are you using the razor macro since conditional logic isn’t supported by the usercontrol one…