Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8901

Conditionally required image field

$
0
0
Hi, In my current project, I have a hero area that supports the following two layouts:Large Hero Area, that requires an image and a heading text.Small Hero Area, that requires only a heading text. In my page type I have the following three fields:HeroAreaType (DataType Text, Required, Form Control: Drop-Down list, DataSource: list of options, Data: 0;Large Hero Area, 1;Small Hero Area), for the author to select the Hero Area Type.Heading (DataType Text, Required, Form Control: Text box): for the author to insert the heading text.Banner (DataType Text, Form Control: Media selection): for the author to select an image from the media library.What I need to do, but I wasn't able to find any relevant documentation, is when the author selects the 'Large Hero Area' in the @HeroAreaType@ list then the @Banner@ field should be treated as required and if no value is set for the @Banner@ a relevant validation message to be displayed to the author. Also if the author selects the 'Small Hero Area' in the @HeroAreaType@ list, then the @Banner@ field should be treated as optional. I tried to use the @General Condition@ Validation Rule of the field @HeroAreaType@ in the relevant Validation section, but I could not make it work.Is it possible to achieve such conditional behavior by using the @General Condition@ or any other build in validation rule? If so please direct me to a relevant example or showcase. If not, what is the suggested way to achieve such behavior?I' am using Kentico 12Sp1 MVC.Thanks in advance,George

Viewing all articles
Browse latest Browse all 8901

Trending Articles