Features
- Full SP2007 and SP2010 support for both lists and document libraries
- Works for all standard field types (Custom field types are not guaranteed to work)
- A field can be used in multiple section
- You can have a section displaying all fields
- You can have a section catching all orphans (fields that are not displayed in any other section). Useful if one adds columns to a list without updating the script call.
- Highlights section if a field fails validation upon save
- Use a URL query string parameter to expand a specific section
Browser compatibility tested in:
- IE6 (Works in SP2007 only due to SP2010 incompatibility with IE6)
- IE7
- IE8
- Firefox 3.6.13
- Google Chrome 8.0.552.237
- Safari 5.0.2
How to use this solution
For SharePoint 2007
/Lists/Accordion/NewForm.aspx?toolpaneview=2
/Lists/Accordion/DispForm.aspx?ID=1&toolpaneview=2
/Lists/Accordion/EditForm.aspx?ID=1&toolpaneview=2
For SharePoint 2010
Add this code block to the CEWP:
var accConstructor = {sections:[{name:'First section',fields:['InMultipleSections','Column1','Column2'],mouseOver:'This is the first section',sectionStyle:'',clickFunction:''},
{name:'Second section',fields:['InMultipleSections','Column3','Column4','Lookup1','MyMultiLookup'],mouseOver:'This is the second section',sectionStyle:'',clickFunction:'secondSectionClick(this)'},
{name:'Third section',fields:['InMultipleSections','Title'],mouseOver:'This is the third section',sectionStyle:'',clickFunction:''},
{name:'Forth section',fields:['Column5','Column6','MyPeoplePicker'],mouseOver:'This is the forth section',sectionStyle:'',clickFunction:''},
{name:'Attachments',fields:['attachments'],mouseOver:'',sectionStyle:'',clickFunction:''}],
settings:{viewAllFields:{show:true,position:'bottom',name:'All fields',mouseOver:'This section shows all fields',sectionStyle:'',clickFunction:''},
orphanFields:{show:true,name:'Orphans',mouseOver:'All orphan fields',sectionStyle:'',clickFunction:''},
bgColor:'#8EB4E8',
hoverColor:'#FFF68F',
selectedColor:'#C6E2FF',
formBgColor:'#C6E2FF'},
clickFunctionShared:'clickFunctionShared(this)'};
function clickFunctionShared(elm){
var acc = $(elm);
// This code is run on click on any section
}
function secondSectionClick(elm){
var acc = $(elm);
var arrOfFields = acc.attr('fields').split(',');
alert("The fields included in the second section is these:\n"+arrOfFields);
}
init_buildAccordionForm(accConstructor,'1');
You must change the “src” to “AccordionForSharePointForms.js” to match your local file. If you like to use a local instance of jQuery, change that as well.
accConstructor: The object constructed in “var accConstructor”.
selectedAcc: Integer that specifies which section to preselect.
Variable “accConstructor” explained:
Attachments
How to find the FieldInternalName
Link directly to a section:
Note:
Overriding native SharePoint functions
I have added one line to the bottom of the function:
g_elemRTELastTextAreaConverted=document.getElementById(strBaseElementID);
preSaveHighlightAccOnValidation();