AnsweredAssumed Answered

Using Forms service for webscript actions

Question asked by loftux Moderator on Oct 24, 2012
Latest reply on Sep 17, 2013 by eric.soto
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).

Outcomes