Adding Required Checkbox on Custom Form Control
Hello,
I've created a dropdown list custom Form control following this example:
http://blog.falafel.com/blogs/11-03-14/Creating_Custom_Form_Controls_in_Sitefinity_4_0.aspx
I want to add "Required" checkbox to make the dropdown field required like those of the built-in form controls. Or at least make it as required field without any checkbox option on the designer.
I tried to set the "Required" property of ValidatorDefinitions to True
as in this
example but it doesn't validate at all. http://blog.falafel.com/blogs/11-02-27/Input_Validation_on_Sitefinity_4_0_Forms.aspx but it didn't work for my dropdownlsit.
Could someone guide me how to add a required field checkbox or just to make the field required to custom Form control please.
Thanks.
Hello Mayvelous,
I think that the Required field works but the dropdown form element is such an element that actually always has a selected value, because the title and the value are the same, so "-- Select country --" is a valid selected choice.
Did you try for example with a radio button list or a custom textbox?
I'm not quite understanding your reply.
My dropdownlist was custom build form control and it has different text and value fields. For "-- Select Country --" field, the value is null string "".
I just want to add "Make required" checkbox and the error message field like those in the built-in textbox form control and how that validation is done via JS or in the form control code.
Any help on how to go about please?
Thanks.
Hi Mayvelous,
In this case I will need the source of your custom form control so I could see what is going on. Could you send it to us?
Kind regards,Please download the project file from here: http://www.mediafire.com/?b4onqrl7q0bn7om [11kb]
Thanks.
Hi Mayvelous,
Just a quick question - if you drop a regular drop down list control could you see all its settings under Advanced and copy them to your control - I especially talk about the Validator setting - it must be set to "Telerik.Sitefinity.Web.UI.Validation.Validator". Then, if you write your own DropDown field control why don't you inherit directly from FormMultipleChoice instead of FieldControl - that way most of the logic will be ready out of the box that way.
Best wishes,Hi Lubomir,
The Validator setting is the same as you mentioned and so as many other fields.
Thanks for the hint to use FormMultipleChoice but I wanted as dropdown list item and not multiple choice radio buttons so I'm inheriting from FormChoiceField instead and following the sample here
I'm still having some problems and am asking for help in the other post.
Thanks.
Hi Mayvelous,
In this case can we consider your issue as resolved or you have any more issues?
Kind regards,It's still not working for me and I don't get any proper respond on my error I posted in the other post so I don't know whether to close this or not.
Hi Mayvelous,
What is your other post? We should stick to only one place where we answer your questions so please choose one of the two threads to be the active one and we will close the other one.
Best wishes,As mentioned above, it's here: http://www.sitefinity.com/devnet/forums/sitefinity-4-x/sdk/dynamic-dropdown-choicefieldelement-in-custom-module.aspx#1812716
Should I repost whatever I've posted there in this thread cos' that thread has been closed.
Hi Mayvelous,
I would suggest to send your entire custom form control project in a new support ticket. The exception that you mentioned in your other forum thread might be coming from something else in your source that we can't see at the moment.
Greetings,