cancel
Showing results for 
Search instead for 
Did you mean: 

Using Forms service for webscript actions

loftux
Star Contributor
Star Contributor
I'm using the Share forms service to render a Form, the form collects data that is posted to a webscript and processed.
The data in the form is not persisted against a node, so I have no data model for the form fields.
What I have done is define the form (shortened here)

   <config evaluator="model-type" condition="cm:content">
      <forms>
         <form id="printorder">
            <field-visibility>
               <show id="sendto" force="true" />
               <show id="contact" force="true" />
               <show id="bestdata-objnr" force="true" />
               <show id="bestdata-objnamn" force="true" />
….
            <appearance>
               <field id="bestdata-objnr" label-id="label.printorder.bestdata-objnr" mandatory="true" set="copyfirm">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="bestdata-objnamn" label-id="label.printorder.bestdata-objnamn" set="copyfirm" mandatory="true">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
and then calling it with
         var templateUrl = YAHOO.lang.substitute(
               Alfresco.constants.URL_SERVICECONTEXT + "components/form?itemKind={itemKind}&itemId={itemId}" +
               "&mode={mode}&submitType={submitType}&formId={formId}&showCancelButton=true",
               {
                  itemKind : "type",
                  itemId : "cm:content",
                  mode : "create",
                  submitType : "json",
                  formId : "printorder"
               });
The displayed form is then posted to a custom webservice url, not the default form processor.
The reason for defining it as a "cm:content" although it actually is not is the necessity for the forms service to have a forms processor. And it works (partly), the form is displayed as expected, I can post the json data and process it.
What is NOT working is constraints, if I set any field to Mandatory, that is gracefully ignored. Or have the file object picker start at correct location.

What I want to do
Define a form definition, it should not be dependent on any object, action or workflow. It is processed against a new FormProcessor that basically just returns whats thrown at it in form definition.
- I need to extend FilteredFormProcessor. What methods of the abstract methods of my new form processer needs to be implemented?
- What do I need for (if anything) in the form processor for object picker to work?

Maybe there is some entirely different way of doing this. But I like to use the forms service, I have already created custom controls for my need, so I dont want to use an 3rd party forms engine, with the Alfresco one I get so much by default (like validation).
1 REPLY 1

eric_soto
Champ in-the-making
Champ in-the-making
Loftux,

I know this is a relatively old post but have you tried using Alfresco.util.PopupManager.displayForm()? For a sample on how to use it click here. Just pass it your properties for formId, itemId, itemKind, and mode.

I hope this helps. Cheers.