Orchard Custom Form DropDownLists - c#

After a bit of playing around with Orchards' Custom Forms module, i decided i wanted to use a dropdownlist to select a particular person with their email as the value for that selected option. While i was creating the form i couldn't see anyway you could set values to your options.
See below image for example:
Don't suppose anybody has come across this before or has a suggestion?

In your case I wouldn't worry about having different text and values for the fields. It's also potentially dangerous to make the recipient email an input of the HTML form.
The Custom Form Rule Event provided with Orchard gives you no way to look at the values of the content type created by the form. So, you're probably going to have to write your own. You should be able to base this on Orchard.CustomForms.Rules.CustomFormEvents.
Armed with this you'd be able to create new rules for each possible dropdown value and set the email address in the action for each rule.

Related

Bot Framework (.Net) - Send additional parameters with button using PromptDialog.Choice()

I'm trying to learn Bot Framework using .Net and I have an application which displays buttons and based on the option selected, display more buttons or a list. What I want is, to send a hidden ID/parameter with the button so that when user clicks on the button, I can access the hidden parameter. I'm not using cards for this. I just want to display the buttons. Can anyone help me with this? I know this can be a very basic question but I couldn't find how to this without Cards.
First of all, PromptDialog.Choice behind the scenes creates a HeroCard with multiple buttons (which are basically the PromptOptions passed, see the code)
One way to pass a hidden parameter would be specifying the ActionType PostBack to your button and fill the Value property with the hidden parameter. PostBack is the way to go here since the message will be posted to the bot but client applications will not display this message (however, please note that not all the channels support the postBack action type). See this for more information
Now, since you are using PromptDialog.Choice you will have to override things in order to be able to specify the PostBack action type, since by default, the buttons created with the Choice are using ImBack (per this code)
You will have to put together a custom PromptStyler, override the Apply<T> method and add your logic to change the action type and set the buttons in the way you want based on the PromptStyle used and pass that custom styler to the PromptDialog.Choice.
By default the PromptDialog.Choice uses PromptStyle.Auto.

Restrict items to select by extension in Sitecore8 Internal Link Field

I have an Internal Link Field in a custom template in Sitecore 8. I want the user to use the Link Field to ONLY select a (say) PDF File from the Media Library. When clicking on "Insert Link" the Media Library pops up, scoped to the node I set in the DataSource Field. In here, I want the user to only see PDF files.
Is there any chance this can be done with the Internal Link Field?
Or maybe some other way around that problem? I don't want to have a custom Field Validation that prevents the user from saving the actual item. I'd rather have the user not selecting any "wrong" files for the field.
Thanks in advance.
Out-of-the box you will not be able to do this. You have a few options that I can think of right now:
Change the field type to treelist (or treelistEx) and use Datasource=/sitecore/media library/....&IncludeTemplatesForDisplay=Pdf,media folder&IncludeTemplatesForSelection=Pdf as datasource - your datasource will do exactly what you want but your editors will be able to select multiple pdf's (this can be checked with validation but you wanted to avoid that)
Change field type to droplink and use query:/sitecore/media library/....//*[##templatename='Pdf'] as datasource - now they can only select one, but you get a flat list of items and that might be not that easy to work with
Create a custom field type for a link with datasource: this is more work but could give you exactly what you want and it seems like it has been done before.

Modifying form fields with FieldEditingControls

I’m trying to add a honey pot field to our contact us form. When I add hidden field to the form via the Kentico GUI (with conditions making it invisible) it’s not available in the source so I don’t think it will actually work. However I also tried adding the form via the GUI and trying modify the style on prerender in my form control won’t work either (Code below). It is odd as it will actually let me change the value of the field in my form control but not the styling. Is this typical of Kentico and is there a solution to trying to implement a honeypot field? I had suggested we just add more validation methods to the form, but I was told that they want the same behavior as the existing forms.
Here is the method I’m using.
((CMS.FormControls.EditingFormControl)viewBiz.BasicForm.FieldEditingControls["Pooh"]).Style.Add("display", "none");
Thanks
Under the advanced properties of the field input, you should be able to apply styles to the input. You could set display:none; there to hide it from the user, but still have it available in the source.
I'm also going to create a form control for this so that it can easily be applied to another with some validation functionality (i.e. a redirect to captcha)

How do I know what is the type of control textbox/checkbox etc in controller?

I need to be dynamically build controls like textbox, checkbox, radiobutton etc by making a Ajax request and downloading the HTML. However once enough controls are on the screen and user submits the form, I need all the controls and it's posted values. Posted values are easy to get using Non sequential indices in Asp.Net MVC. But, how do I get which control's value it is? Put simply if the form has submitted the value "Hello World". I need to be able to know from where did the Hello World. Was the textbox that submitted this value or the textarea?
I don't need anything else like ID, name etc. Just need to know the type of control whether it was texbox, textarea, select or which one.
when you dynamically build these client elements, you give them a name so they will post to the server.
just follow a naming convention like:
textarea1,textarea2...
txt1,txt2,...
then at the server, to collect the values - take all the keys that start with textarea to collect the values of textAreas...
a nicer way will be to have a model with lists for each type, and when you generate the client elements, build their names so the values will be mapped to the correct list by the ModelBinder
the syntax for these names is a bit nasty so work with client templates
I used this post by haacked when i needed to build something like this
You need know more about http get or post.

how to check that any form field data is changed or not?

i am working on a asp.net web app in this application when customer logged in then his/her
personal details displayed in form fields (e.g. full name in name box ,age in age box etc) for getting data first i fetch the data from ms sql then assign them to ICustomer interface properties this interface is implemented by customer class.
And we also have a update button on customer information page so if without changing any information if a user click on update then unnecessary it will go to server and come back and the same data updated in database,so what i am trying to do is to just detect whether something changed in customer form then only update functionality should work.
i have two option
just use Java script and detected the text change then unable update button.
make a temporary reference of ICustomer and compare it to the older when then process by making something true or false.
so please suggest me the best approach for it or any other method.
if question is unclear then just comment on it i will explain more.
If you're using the formview or detailsview control in your asp.net webpage, then you can use the OldValues property of the forms's itemupdating event to compare the values before posting to your database. I believe the form's viewstate must be enabled for this to work.
protected void myFormView_ItemUpdating(object sender, FormViewUpdateEventArgs e)
{
// Access the old values
e.OldValues...
Here's a full example using the detailsview.
JavaScript may help you, but it's very unreliable. I say go with the second option. Store the ICustomer object in a Session variable and compare it with the new one.
If you're using TextBox controls, one option is to use the TextChanged event to detect changes.
You should go to 2nd option if the size of your object is not very large as you have to store the old object before comparing to the new object of Icustomer to detect any changes. Otherwise use javascript to detect the changes on the text fields. but as you know its not very much reliable.
the main problem with the Javascript option is that what if user changes value and again change to it's previous state in that case also it'll shows value changed.

Categories

Resources