Making dynamic content forms with checkbox - crafter-cms

How do I make my content forms dynamic in CRAFTER CMS?
I want my form to hide/unhide other form controls when a checkbox is checked.
I also want to require certain fields (form controls) to be filled out when a checkbox is checked or not.

The form engine doesn't currently have any pre-built relationships/interactions between form controls. That said, form controls are just simple javascript that you can create/add or extend.
Here is a link to a short guide on creating custom form controls: https://docs.craftercms.org/en/3.0/developers/extending-studio/form-engine-control.html

Related

Create and Load Custom Controls into FormView

i have a Form View in MFC. I try to include a dynamic Field, like C# User Control, where i can include other Controls, based on the clicked Item in the Lists.
I already found a User Control in Toolbox.
My question is:
Is it possible to create Form Views in Ressource View and add it to my Form View dynamically?
Can I use the Custom User Control to Replace it with my created FormView?
My FormView looks like this: Imagelink (Green Box should be filled with selected Control).
It is embedded in a TabView Item.
Or if this didnt work, i would bind different FormViews (Create same FormView with different green controls) to that TabView without the Ressource View at Runtime, is that possible?
I'm new to MFC and created my Prototype in C# .NET, so this is very hard to understand :)
I've found the solution. I'm now using different Groupboxes to arrange the Controls. I can show and hide them. Only the positioning should be a little bit hard.
https://www.codeproject.com/articles/32969/cstackablegroupbox-class-to-hide-group-of-controls

Issue related to Kentico on-line form (bizform) validation

I have created a form using Kentico on-line form and applied the built-in "required" validation on it. Whenever a textbox is empty then a required validation is shown. Now, I have entered a value in the textbox and press tab from the keyboard but the required message does not disappear. I want to remove or hide the message from the form when the user enters a value in the text box before the submit button is clicked.
How to resolve this issue?
I don't recall this being something that Kentico handles out-of-the-box. You'll most likely need to add some custom client-side script for this. Typically - where I work, at Ridgeway - we use custom layouts for forms, as the standard layout is fairly table-rich.

Can you compute which custom control to use?

Think "computed subform", but in Xpages.
On one of my custom controls, depending on a certain value, I want to either present a custom control that renders a drop-down list using a combobox or renders an input box with a type-ahead.
This is on a custom control that renders a view, with all view configuration choices handled by a document rather than design, so several different views utilize the same custom control.
For example: I have a By Status view using the custom control that has status as the first column and we use a combobox to allow the user to select which Status value to filter by. Another view is sorted by Requisition number and I want to use a type-ahead instead of the combobox.
My preference is to use the same dynamic view custom control for both and have a formula that determines which of the two (comboBox or inputText) to use. How do I compute which custom control to load?
(Credit for the dynamic view control goes to Scott Good's folks over at Teamworks Solutions.)
During it's life cycle, an XPage exists in two places. First of all a representation of the XPage's relevant components is stored on the server. Then the page goes through a lifecycle, retrieving properties from documents, checking which components should be rendered, retrieving the data for any repeating control such as a View Panel etc., and passing the relevant HTML to the browser. The browser is the second place it exists.
So you can't compute a custom control as such. All you can do is set the loaded property, and loaded needs to be based on a non-dynamic calculation such as a viewScope variable, the current XPage name, a view name stored on the XPage etc. What you would have difficulty doing would be using a different custom control based on data on that row entry.
The other option is the Dynamic Content control or Switch control from the Extension Library. Both are similar to using the loaded property, in that you're putting both custom controls on the page and choosing which to display.
From what you're describing, the loaded property should cover what you need.
Some time back I saw this question on StackOverflow where the author had used Include Page control (xp:include) to include custom controls using pageName attribute based on formula.
<xp:include>
<xp:this.pageName><![CDATA[${javascript:sessionScope.ccPageName + ".xsp";}]]> </xp:this.pageName>
</xp:include>
Similar to the technique described by Paul Withers in his answer the attribute of pageName is also computed on page load.

Can I use one form for add and edit List Items?

I created custom edit form and custom add form for my List. Both forms have the same FormFields and they differ only by ControlMode tag. In add form ControlMode="New" and in edit form: ControlMoe="Edit".
When I try use edit form as NewForm, in all input box I see text "... field value" insted of empty box. And when I try use add form as EditForm, all input boxes are empty insted of field value.
Can I somehow use one aspx file as newForm and EditForm at the same time to not duplicate aspx files?
For sharepoint webpart page(site page): No you can not have same form for both
For Sharepoint application page: yes you can. you have almost complete control over you application page.
For more info about difference in site page and application page:
http://akifkamalsyed.wordpress.com/2010/06/12/sharepoint-application-pages-vs-site-pages/
http://jwalin.wordpress.com/2008/05/26/difference-between-site-pages-and-application-pages/

XPages templating dialog boxes

I am currently on a project redesigning an existing traditional domino web application to XPages. This application contains a web form with quite a lot of helper dialog boxes. Also notifications and validation and confirmation is done through dialogboxes.
I know I can create a custom control for each dialog box and add it to the Xpage and call the show. I even managed to load it dynamically using a dynamic content control with a facet for each dialog. Since the dialog cc contains a show() in the onClientLoad. It is easy to open a dialog by switching the content of the dynamic content control.
Still, adding all these custom controls to my XPages feels inefficient and really clutters the design tab. What's your take?
I would prefer setting the content of the dialog dynamically (Like in traditional domino you would define a form for each dialog). Is that possible?
If not is it possible to load a custom control dynamically (Like using a computed subform)?
Also for confirmation boxes I need the OK button to execute different code for each confirm. What would be the best way to implement that? Add custom parameter "functionOnOk" to the "dlgConfirm" custom control and evaluate that in the submit button?
PS: I am still using panels with dojoType=dijit.DialogBox, but will change those to extlib dialog boxes. For the confirm and messageboxes I am now using client side dijit.Dialogs with mark-up in code, but I would like the markup in XPages as well.
I know there are issues with panels with dijit.Dialog, because Dojo moves the dialog in the DOM, which prevents any SSJS in the dialog running. I don't know if that's also an issue with dijit.DialogBox, but I suspect it could be. Jeremy Hodge did some code to workaround that.
However, I would strongly recommend using the Extension Library control. Client-side dijit.Dialogs are likely to be much more difficult to code and will not allow any SSJS interaction. I'm not aware of any Dojo properties not available in the Extension Library control, and the Extension Library control also allows you to open or close the dialog both in CSJS or SSJS. It also allows you to specify an area to refresh on close.
In terms of the properties, preload is there purely to speed up showing. Are you using the refreshOnShow property? This ensures the URL or content is refreshed each time the dialog is shown. The Extension Library chapter on dialogs has a table covering all the properties. You can set the URL to point to another XPage or another web page. This may allow you to use the Dynamic Content control to pass parameters to switch the content that should appear.
In terms of the code behind the OK button, if you use the Extension Library dialog, you have all the functionality you would have outside the dialog.

Resources