DecCF./ˈdɛk.ɛf/

Organize inputs into pages, tabs and groups

Use Family workspace under Create → Examples to try an application with several input pages. Family details and members are tabs on the Family page; the Properties & costs page contains an unframed object and a framed expenses group.

Choose a layout

DeclarationWhat the user sees
input.domain({ ... })One optional root holding the application's named inputs. An application can have at most one domain.
input.section({ ... })A named input page in the application's navigation, even when it is the only section.
input.aspect({ ... })A tab. Consecutive aspects share one tab area. An ordinary field between aspects starts a new area.
input.group({ ... })A titled frame around related fields.
input.object({ ... })Related fields in the normal layout, without a frame.
input.groups(source, { ... }, options)One connected group per source row, with a protected ID and current name.
input.objectArray([ ... ])Editable cards with add/remove actions, one per row.
input.objectArray([ ... ], {type:"table"})A Tabulator table using the same field controls.
input.hidden(value)A retained value with no visible field.
input.readonly(value)A visible value that cannot be edited. readOnly is an alias.

These pages and tabs belong to the application's own input area. They appear when users open the application.

The navigation includes Model inputs when fields outside named sections are available. Each available section has its own page in the same menu. Run input contains calculation settings, and Scenarios contains named alternatives. Changing pages preserves edits; calculations run when you select Calculate or Update results.

To hide either optional page, add calculator settings to your defineModel declaration:

Both settings default to true; set only the page you want to hide. Each value must be true or false. With scenarios disabled, the Calculator uses the base inputs and does not add suggested alternatives. Existing saved scenario data stays in the case and becomes available if you enable scenarios again.

The Calculator opens the first available section, then a remaining system page if there are no sections. The hamburger appears when more than one page is available. When there are no input pages, the toolbar and Update results remain available. Visibility rules can remove and restore pages as values change; the Calculator selects an available replacement and keeps your values.

Domain, section, aspect, group and object all take a named object, not an array. Give them a title with {ui:{label:"Family"}}; otherwise the named field supplies the title. Keep sections directly inside the domain, or register them as separate root preconditions. Each editable leaf still needs its own input declaration and default value.

Add optional ui.note text to place an explanation after an object's fields, at the end of its page, tab or group:

Include savings in a section or register it as a model input. The note is plain text and adds no saved input value. Omitted, blank and non-string notes display nothing. Notes also work on ordinary objects, domains, sections and groups; scalar fields, arrays, compact sum dropdowns and custom widgets do not display them. App language resources can translate the note like other authored labels.

Enter a model in the editor

preconditions: domain registers the root under the name domain. You can also use preconditions: {domain} or choose another root name. Nested field handles such as salary are then available through ctx.get(salary) without registering them again. A nested object-array handle can be used with repeat(); use its item.data projections for individual rows.

Existing models using flat preconditions, objects and object arrays keep working. Adding layout changes how fields are presented, while values remain nested objects and arrays. Saved cases and scenarios retain inputs on every page and tab, including those currently hidden.

Keep one group per source row

Use deccf.input.groups(source, fields, options) when another list controls which named groups appear. For example, give each project its own editable cost list:

The result is an ordinary object array containing {id, name, costs}. The protected hidden id follows the source key, and the protected name follows its current name as the group heading. Keep id and name out of the field map. Optional label names a different source string field; it defaults to "name". Optional where includes rows matching all scalar equality conditions; omitting it includes every row. Optional rows defaults to []; supplied rows require a typed id and editable fields matching the field schema. An optional typed name never overrides the source label. Groups without a matching initial row use their fields' defaults. Optional ui, title, type ("cards" or "table"), visible and required retain their ordinary object-array meaning. Other options are rejected. Invalid source, label, filter, reserved fields or initial rows produce declaration errors.

Adding, removing or reordering projects updates the groups. Renaming a project updates its heading. Each surviving project's edited costs stay with its stable key. The outer list has no separate add/remove buttons; each nested cost list has its own controls. Use budgets.item.data with repeat() and column() for normal calculations. The complete API reference includes a runnable project-cost example that sums nested costs within each repeated group. Saved cases, scenarios and submitted values use ordinary arrays and Money values.

Connect lists across pages

Declare people once, then let that list control the rows on income, municipality and ownership pages. Bind the target key to the source ID and use a read-only name to make each row recognizable:

The connected list follows the adults' number and order. Renaming a person updates their displayed name. Removing a person removes the corresponding row; adding one creates a row with the template's .5 share. Existing shares remain attached to their person IDs when the source order changes. Connected lists have no independent add/remove actions. Omit connectedWhere to include every source row.

Use an explicit item template with an empty initial array or when you need different initial values per person. Seed rows use constant IDs and the same hidden/read-only field types as the template; the template uses the source projections. Connections can also live inside each home or loan row, so each property keeps its own editable ownership values.

Add {type:"table"} to a loan or connected-list declaration for a Tabulator table. Hidden fields stay in the submitted values but do not become columns. Read-only fields display the source's current values. {dynamic:false} also removes add/remove actions from an ordinary fixed list. To label an ordinary add button, use {ui:{addLabel:"Add a loan"}}; omitting the label leaves only the plus sign.

The Complete household calculation example uses adult groups for each person's own loans and a separate shared loan list. Its municipality and income pages follow the adult members; the municipality page has Before and After tabs with independent rate assumptions. Homes and child benefits use simple adult or shared choices. The advanced January-1 tax ownership inputs remain separate.

Compact cost groups

Use a sum dropdown when related amounts should occupy one field until someone needs the details:

The closed control shows a read-only total of 4,200 SEK. Expanding it opens the editable fields downward over the fields below. Editing a component updates the total. Escape or a click outside closes the panel. The value remains an object containing the five Money values; no extra total field is added. Numeric leaves contribute to the summary, while text and booleans do not. Different currencies keep their own subtotals. input.object accepts the same options as its Object alias.

Show fields for the selected decision

Use a sibling condition to show a field only for relevant choices:

Selecting Sell hides the market value; Keep and Buy show it. Each row in an object array uses its own decision. Hidden fields retain their values and validation, and switching back restores the entered amounts. In the complete household example, Keep hides purchase price, sale price, and both transaction costs; Sell hides market value, amortization base, and both transaction costs.

Use visible:false for a field that should always stay out of view, or visible:true to show it. A family field can use visible:{field:"role",values:["adult"]} to appear only for adults. In the household example, selecting a child hides the contribution weight and excludes that person from adult income, municipality and current loan/ownership lists. Names, birth dates and roles remain available for the family calculation.

An ordinary string field can offer names from an editable list while storing the selected item's stable ID. For example, put this field beside a list at domain.people.members whose rows declare id and name:

Use the exact declared input path; the list can be on another page or registered as a separate root input. The key must be a declared ID or string field, and the label a declared string field. Optional where includes only rows matching every scalar equality condition; here it lists adults. Omit where to list everyone. Each dropdown keeps its own selection. Renaming, adding or removing list items refreshes the names on hidden pages and in nested cards too. Saved cases and scenarios keep the selected IDs when names or list order change.

A removed or filtered-out selection stays visible as Unavailable and invalid until the user chooses another item; the field never silently selects someone else. Blank names appear as Unnamed item with a number. Static ui.choices, such as Shared above, remain available even when the source is empty or no rows match. Their values are ordinary strings whose meaning comes from your model. All choice keys must be nonempty and unique across source and static choices. With no available choices the dropdown is disabled; invalid paths, fields, filters or duplicate keys show a configuration message.

Reorganize an existing application

Use Prompt a small change in the Input- and calculation model editor to reorganize existing input pages, tabs and groups. You can reorganize the whole input area in one request while keeping the application's purpose and calculations. For example: "Split the existing inputs into Family, Budget, Savings and Home with loans pages. Keep the calculations and saved input values."

Input pages are defined with the input declarations above. The Presentation editor controls result and report widgets. Reorganizing inputs does not require changing that presentation.

If existing groups are named objects, change their declarations from input.object to input.section, keeping the same fields and names. Register the sections with the same precondition keys, for example preconditions: {family, budget, savings, housing}. You do not need to add a domain. Keeping these keys and their value structure preserves saved input values and scenarios.

When a field needs a new saved path, optional ui.initialValueFrom can copy its former value while opening a saved case or scenario draft:

Only an absent target uses the saved source value. Explicit new values, including zero, win; if the source is absent the normal default is used. Paths name object fields from a root input, without array-row selection. Invalid paths, inherited properties and accessors are ignored. The saved source data is not changed. This affects draft initialization; keep old fields optional where direct saved input records must still validate. See Values and inputs.

When the replacement field uses different units, add ui.initialValueScale. For example, convert a former monthly amount into an annual amount when opening a saved case or scenario:

The scale defaults to 1 and must be a finite positive number. It multiplies a saved finite number or Money amount, preserving the currency and other Money data. An invalid scale, unsupported source value or nonfinite result uses the declared default. Explicit target values are never scaled, so saving and reopening an annual amount keeps that amount. The saved monthly source remains available; the calculation model must accept that former field and use it when the annual field is absent.

Saved scenarios that select the former field individually follow the same path and unit conversion when that field is hidden and exactly one editable replacement declares it as initialValueFrom. They open with the replacement field's label and units and save its new selector. If both former and replacement fields were selected, the explicit replacement value wins. Fields under protected groups, readonly fields, connected values and array-row selections retain their normal restrictions.

Case navigation contains the available input pages and enabled Run input and Scenarios pages. Each page has a clear heading, and fields show their names before their controls. Money fields show a currency addon and percentage fields show % beside the entered value.

Use the hamburger button to open the page menu when more than one page is available. Switching pages or tabs keeps the values you have entered. The menu follows the input area's width as you resize it.

On desktop, inputs and results share the available width in both an open application and the editor preview. Drag the divider between them to give either side more room. You can also focus the divider and use the left and right arrow keys; Home gives inputs the smallest allowed share and End the largest. Your browser remembers the chosen width. On a small screen, results appear below inputs.

The case toolbar spans the whole application above inputs and results. Use Save case, Save case as new and Open case there when case storage is available. The application name remains at the top of the input area, and Run input and Scenarios use the same heading style as section pages.

Select Update results after changing inputs or scenarios. If a calculation fails, the error replaces the results. Where Review inputs is offered, use it to reopen the inputs, make a correction and calculate again. The divider returns with the reports after a successful calculation.

The scenario field picker follows the same page and group structure. Open a branch to choose individual fields, then use Back or the breadcrumbs to return to another group. For fields inside editable lists, one scenario value applies to every row. See Create scenarios in the Calculator.

Output tables use compact columns, and generated labels are made easier to read: asset.savings.state appears as Asset - Savings, state. An explicitly supplied output label remains unchanged.

Alternative object fields and cards

Use input.Object(variants, {title}) for one selector followed by the active fields. The lowercase input.object alias behaves the same way. The three typed input.objectArray modes create cards with changeable, fixed or unique types. See Offer alternative object inputs for all four calls, defaults and validation.

Validate relationships between fields

An object's constraints checks related values together. This works on a domain, section, aspect, group or ordinary object, including an object used as a collection row. For example, require the current age, retirement age and life expectancy to stay in order:

Each rule has left and right paths relative to its owning object and a relation: <, <=, >, >=, == or !=. The default is no rules. An optional nonempty message explains a failed relation; otherwise the error names both fields and the required relation. Validation identifies the left field, using the same field errors as ordinary input validation.

Paths traverse ordinary object fields and end at numeric, Money or date inputs. Numeric scalar kinds can be mixed. Money endpoints must use the same currency and compare nominal amounts. Dates compare chronologically; a year-month means its first day. Unknown paths, array-row navigation, prototype keys, getters and incompatible endpoints are rejected when declaring the object. Put a rule directly on each concrete object variant when using variant inputs; a path cannot cross a variant chooser.

Rules validate the complete resolved input tree after scalar validation, including changes supplied directly to a nested leaf. Optional missing endpoints and endpoints already failing scalar validation produce no additional relational error. The input values remain unchanged. Use the same mechanism for minimum/maximum rate assumptions, dates, or monetary limits; no validation callback is required.

Keep the financial model readable

The mini-calculators keep typed inputs, domain structure and form labels together. Their calculation code then declares the financial entities, accounts, flows and other financial objects before composing the model. A calculator that only needs formulas can omit accounts and entities.

Read the same input values throughout the model. Use native repeated components and sums for collections, financial formulas for growth and payments, and analysis declarations for scenarios or goal searches. The separate presentation selects standard account, flow and metric results through widget configuration. This lets the same widgets serve different calculators without a custom report format for each one.