Search code examples
osgiaemsling

How to build a simple form in CQ5


I have started a new AEM project in eclipse that has

  • core
  • launcher
  • tests
  • ui.apps
  • ui.content

I have a local instance of 5.6.1 running and I would like to create a very simple form (firstname, lastname) and have it persist data such that I can view data for all forms submitted. Also, I would like for the form to be approve/rejected (e.g. user1 submits the form, user2 accepts/rejects it).

I'm new to AEM and have been looking at docs and trying to find a tutorial for it for a while now but haven't been successful.

Question

Can someone please walk me through how to accomplish this simple form? Once I can do this I can build-up more functionality on my own.

What I've tried

I tried to create a form in the Geometrixx Media site but I don't see form template there.

enter image description here

I also tried following this tutorial but it didn't help since its for 6.0 and is confusing to the point that I don't follow it at all.


Solution

  • You need some basic understanding of how cq/aem works in order to accomplish the task you started. But in the simplest use case, you need the following things:

    1. You can create new cq page component and define in the jsp the html markup of the form you need
    2. Or you can build a page/component using the /libs/foundation/components/form components. Start reading the best from the page developing forms.

    The form action can point to the component itself where you can store the data (if you create a page with a component who is responsible for rendering the form) and in this case you can let sling post processor to handle the data storage or you can define your own action with a servlet where you can create a node on your desired location.

    The second part of you question is about approving/rejecting submitted data. I guess, that you are talking about workflows. Every time the form is submitted you have to create a new node (or let sling to create it) and than start a workflow for moderating the content. You use here as example the implementation of the social comments and the moderation workflow.