Expand my Community achievements bar.

SOLVED

How to Customize Display of Form Components by Region

Avatar

Level 2

With out current implementation of MultiSite Manager (MSM), most of the authors are creating form pages from the blue print so it 
can be rolled our to live copy pages. 
 
There is a growing need to only display certain form components for certain regions or counties. 

For illustration, we have global node as the blue print   and then the country nodes as livecopies.

 

Scenario:

From blueprint (source), create a page with the following form components:

formstart
   text1
   text2
   checkbox1
   radiobox1
   checkbox2
   dropdown1
   dropdown2 
formend

This page is rolled out to the live copy pages and depending on the user's cookie country code, the form  fields
should be displayed according to the rules set.

Example Rule:
formstart
   text1
   if country = "us" or "ca" {
      text2
      checkbox1
    }  
   radiobox1
   checkbox2
   if country = mx {
     dropdown1
     
    }
   dropdown2 
formend

To resolve this requirement:
1st Option:
We created a regional or country container component where you can set a property for the list of countries that will see it.
Inside this country container is an included parsys so authors can drag the form components for that particular countries.
New layout on blue print  source page would be:

formstart
   text1
   country container component : countrycode = us,ca
      **text2
      **checkbox1
   radiobox1
   checkbox2
   country container component : countrycode = mx
     **dropdown1
   dropdown2 
formend

Complications started when you set the form field components inside the country container as required fields
(have constraint values). Even though the text2 and checkbox1 components are not displayed for Germany (based from the rule),
you can't submit the form because it is flagging it as requred field even though it is hidden.

2nd Option:
We created customized form field components ( derived from the OOTB form component) that has the property to display for selected countries.
Also, for that customized component, we added the servervalidation.jsp to do some  validation  for that field component.

The problem with this option is that for the countries where the component should be hidden, it is displaying unnecessary spaces  because it is displaying empty "divs" for the component that was called but was hidden.  It appears that when you add a form field component on a page, it automatically creates  a "div" with class of the component name and the class=section (default classes added by parsys component). 

What is the best way  to customize form components by regions, ensure all form constraints are met and how it relates to the MSM structure (rolling out to the different live copies)?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Yes servervalidation need to be called for the individual field. I do not have sample but is easy iterate through all fields & check the field against request parameter + constraint is required and then add.  If you finding difficulty let me know I will develop one for you.

View solution in original post

3 Replies

Avatar

Level 10

Unfortunately Option1 is bug and should be fixed in next release.  Option2 you can create a clientlib to remove empty divs.

Option1 is right approach has a workaround manupulate overlaying servervalidation such a way that check constraint is  applicable only for visible objects. In that way when you upgrade to latest version you can get rid of overlayed one.

Avatar

Level 2

Hi Sham,

I also think option 1 is the best and cleanest option.  Do I need to add server validation for each form component ?  Can you please provide a sample server validation script?

Thank you so much for providing the resolutions to the 2 options.

Avatar

Correct answer by
Level 10

Yes servervalidation need to be called for the individual field. I do not have sample but is easy iterate through all fields & check the field against request parameter + constraint is required and then add.  If you finding difficulty let me know I will develop one for you.