Sitecore WFM - Show/Hide form fields based on field value? - sitecore

I'm currently using the WFM module in Sitecore to display a form full of fields in sections.
I'm trying to do the following:
Use "Layout Rules" to show/hide a section of fields, depending on checkbox value
When I try to use the Layout Rules on the section I want to hide/show, it doesn't seem to be working (everything is showing).
I've put in the following logic:
NEW CONDITION
where HotelAmenitiesCheckbox field IS NOT EQUAL TO 1
hide element
'HotelAmenitiesCheckbox' is a checkbox field in the form. I've set the name and DisplayName in Sitecore to be exactly what I've typed above.
Can anyone help explain which direction I need to go? This is frustrating with my limited knowledge of .NET and Sitecore's limited documentation.
Thanks in advance!

I have the same issue and haven't been able to find an out-of-box solution with the WFFM module so I came up with this workaround that leverages the Help field of a WFFM field to store a "line of code". I gave the marketers an if statement that they can write in the Help field and when the form loads on the front-end, there's some JS that parses that if statement and hides/shows fields that are dependent on each other. I asked this question just this weekend, and got a lot of help from the community here on Stackoverflow: Conditional Renderings with JavaScript Regex.

Related

Sharepoint designer doesn't show all fields of current item in workflow

When creating a workflow using Sharepoint Designer (linked to a form library) none of my fields from my form show up when I use actions like "set field in current item" or "update list item". The only two fields that show are
"Title"
"Name (for use in forms)"
I have already tried to upload the form as a site content type but was still not able to get the items on my form (using the solution posted here https://social.msdn.microsoft.com/Forums/lync/en-US/37db5742-79ba-49cb-bda5-69172786a339/spd-field-lookup-problem-set-field-in-current-item?forum=sharepointcustomizationlegacy)
please help me ,this problem is hurting my brain :'(
actually doing the thing mentioned here fixed my problem
https://social.msdn.microsoft.com/Forums/lync/en-US/37db5742-79ba-49cb-bda5-69172786a339/spd-field-lookup-problem-set-field-in-current-item?forum=sharepointcustomizationlegacy
at first it seemed like it was not working but I just had to refresh the page -very intelligent mistake :'(
Anyways I'm happy that the problem was solved
This is something which is related to the Refresh a page. Or What you can do is close the site in the Sharepoint designer and then re connect the site. Sometimes refreshing the page does not seem to work.

Show field based on another fields value using rules, WFFM, Sitecore8.1

I want to conditionally show a field in a web forms for marketers form in Sitecore 8.1.
My thoughts was that rules could be utilized to that. the only problem is that it seemingly does not work.
When I set a field to conditionally hide based on the value of another field, nothing happens when I satisfy the condition ie. enter the conditional value.
My intuition here is that the rule editor is not working on realtime on the form (by using JavaScript) but is only something that runs on the server.
Can anybody confirm this? Or otherwise send me the right direction towards realtime updating the form based on rules?
Greetings Mads Buch
You will require to use Javascript. What you can do is to create a custom rule which will be triggered via javascript. You can check the following link on how to create a custom rule https://jeffdarchuk.wordpress.com/2015/06/04/lets-use-that-rules-engine/
Also, you may create a custom type as suggested in this thread.
Thanks

Sitecore Conditional Showing of Fields

So I am rather new to sitecore, and it's a topic that wasn't covered during my training. My questions is just to help point me to the correct term, or documentation on a method to do the following.
I have a definition item, with a ton of field groups, what I want to do is something like:
if Value of Field X is "yes" then collapse/hide Field X or Field Group X.
Does that make sense? Is it a validation rule? or some other kind of rules, is it a workflow I need to attach? Do you place it on just the field I want to hide, or the field that triggers the action?
I appreciate any guidance.
There is nothing out-of-the-box in Sitecore to achieve what you want but there is no reason you cannot create a composite custom field type to do this. The following articles will help you achieve this:
Creating a custom Sitecore Field
Getting to Know Sitecore: Custom Fields, Part 1
Create a new control, inheriting either from Droplist (if the comparison of the value is to be text based) or Droplink (for comparison of ID). You could add a parameter in the Source field of the control to specify what the values that trigger the hide should be.
The underlying control in the Content Editor is just a standard HTML select element. Add onchange events to the control and add your Javascript handler to hide the other controls. Since I could not find a way of adding additional custom css classes to the Sitecore controls, it would be best/easiest to hide all other controls in the same collapsible group after you control. This would mean you would need to group your controls better (or logically at least).
The Javascript will be something like this (the Content Editor uses the Prototype JS framework):
if ($(this).getValue() == 'no') {
// find the parent container of this control and then hide all the next siblings in the same group
$(this).up('.scEditorFieldMarker').nextSiblings('.scEditorFieldMarker').invoke('hide');
}
You can test this by running the above in the console, change out the keyword this with the id of your field, e.g. $('FIELD2292054').
What I am not sure about is how to trigger the hide on initial load, i.e. when someone returns to an existing item, it may be possible by adding to one of the pipelines, but would be better using a JS solution if possible. I'll have a think about this and get a proper code sample up over the next few days.
EDIT: You can add an event handler to sc:contenteditorupdated to handle the content editor being rel-oaded.
document.observe("sc:contenteditorupdated", myFunction);
I wrote up a blog post and put the code on GitHub if you are interested.
Not sure if you have come across Andy Uzick's this blog post.
He wisely talks about hiding fields in the Content Editor and has also created a Sitecore Module called Hide Field Template Extension which is hosted on the Sitecore Marketplace with the full source code to extend.
After reading through and trying the extension, I do feel that it will not completely resolve your issue (how you have described it in the question).
But it will give you:
A mid-term solution to hide a few unnecessary field that some content editors would not like to view.
Fields that are only required by administrators for admin purpose - to de-clutter these fields could be hidden.
Just one thing to bear in mind that it mentions in the requirements Sitecore 6.5 & 6.6. I have not tested it in Sitecore 7. If you are using Sitecore 7, which I think you are, one could modify the source code and make it work for Sitecore 7.
Have a look and share your findings.
Happy Sitecoring!

Date Picker Styling Sitecore

I'm working on a sitecore project where i'm using WFFM (Web Forms For Marketers), I have a form and would like to change the styling of a date picker. By default it appears with -'s. I ant /'s.
One way would be:
$('.scfDatePickerTextBox').val().replace(/-/g,'/')
Theres no option to change the styles? that I know of? Any help guidance would be grateful.
When using WFFM as your forms builder i think it is not possible to style the dateformat.
When adding a date field, it always shows up as three droplists:
see this image: http://content.screencast.com/users/MoonCrawler/folders/Jing/media/627a9a76-de8d-4ad7-9097-81e21d38f54c/2013-01-30_1658.png
If you want to change styles (display) assign different css class. if your date is displayed with -'s in stead of /'s then i think you are using a custom form, you should be able configure the output of the date via the code behind file.
if this does not help, please provide sitecore version, WFFM version and type of form used.

sitecore: webforms for marketers, one form, two pages

I want to use single form for several pages like a block. Sitecore always creates a new form for a page.
How to share/reuse a form?
Depends on weather you are using WFFM 1 or 2 but it is quite similar.
Go to "Presentation/Layout details" for the item (page) that holds the form. You will find a rendering called "Form Interpreter" click this.
If you are using WFFM2 there is a "FormID" field that has your form selected. Just add a similar rendering to every page that you want the form to appear in and select the same form.
For WFFM1 there would be a parameter called "FormID" and a sitecore ID, copy this ID and the same renderings to the other pages including the parameters.
Good luck, Larre
There's an option to select a form to copy from. See paragraph 2.3.1 "Copying an Existing Form in the Page Editor" of this guide.
I had same issue with WFFM MVC version 8.1 (initial release)
our content editors wanted to use experience editor(page editor) and didn't want to change the datasource by going to presentation details and updating the datasource.
It doesn't need any coding
1- Copy /sitecore/layout/Renderings/Modules/Web Forms for Marketers/Mvc Form and give it a name "Custom Form"
2- Set the Data source location
3- Add the new rendering to place holder settings
/sitecore/layout/Placeholder Settings/content
my blog post
http://azadehkhojandi.blogspot.com.au/2016/01/how-to-reuse-web-forms-for-marketers.html