Download the PHP package mediatis/form-logic without Composer

On this page you can find all versions of the php package mediatis/form-logic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package form-logic

form-logic

TYPO3 form logic addon

Form Scripts

The form script is plain javascript which is added to the page. The script is executed on $(document).ready(). It is run in a context with a global variable form. Here are the possible usages.

form.id()

Returns the ID of the form.

fieldId

The parameter fieldId is used all over the place. It is there to target a specific part of the given form. We can hereby mean a specific field (text-1) or its wrapping markup (radiobutton-1), or even a container (fieldset-1).

Furthermore we are always able to target more than one ID: text-1,checkbox-1

For radio buttons as well as multicheckbox fields, we can also target specific input elements of those multi-fields by adding their value: multicheckbox-1:some-value and we can also target multiple values at once: multicheckbox-1:some-value:some-other-value.

Those features can be combined all together: text-1,multicheckbox-1:x:y,radiobutton-1:a.

Whenever the parameter fieldIdis mentioned, those features apply automatically. However, some combinations just do not make any sense and may lead to weird behaviour. For example form.get('fieldset-1:a:b'); will search for all HTML tags inside the given fieldset with the attribute value="a" or value="b", which just doesn't make sense.

Note: For reasons of simplicity, this manual is talking about the fieldId mostly as if it would target exactly one form field, even though it could actually be multiple elements.

fieldId Alias

The form extension is setting the ID of the form and its elements without the possibility to intervene. This is sometimes a bit frustrating, especially if you want to copy the script to another form whose elements may have different IDs.

With an alias you can map your chosen name of a field to its ID and use that name instead of the ID in the following logic. If the element property fluidAdditionalAttributes.name is available and not empty (e.g. introduced by ext:formrelay) the alias of the name field will be set automatically.

Note that the mapped ID has to have the ID of the form as a prefix. We recommend to let an extension (or theme) do the work automatically. The FLUID partial for this work is FormLogicAliases.html.

The features of the standard fieldId are available for aliases as well.

form.get(fieldId)

Returns the element (as jQuery object) inside the form with the given ID. Note: The element is not necessarily the form field itself. It can also be a container (like a grid row element) or a wrapper (like a radiobutton group). Returns all form fields (as jQuery object) inside the form if the given ID evaluates to false.

form.getFields(fieldId)

Returns the form field (as jQuery object) inside the form with the given ID. Note: If the ID belongs to a container, it is returning the form elements within this container instead. Returns all form fields (as jQuery object) inside the form if the given ID evaluates to false.

form.getFieldWrap(fieldId)

Returns the wrapping markup that belongs to the field (or container) with the given ID. Useful to hide a field including its label.

form.exists(fieldId)

Returns true if a field or container with the given ID exists. Otherwise false.

form.val(fieldId)

Returns the current value of the form field with the given ID. Unchecked checkboxes and radiobuttons return 0.

form.val(fieldId, value)

Sets the current value of the form field with the given ID. For checkboxes and radiobuttons, values which evaluate to true mean checked and those which evalute to false mean unchecked. Note: If you want to check or uncheck a specific radiobutton inside a group, you have to adress it in the the fieldId, not in the value.

form.eval(fieldId, condition)

Evaluates the fields value with the given ID according to the condition. Possible conditions:

form.on(event, fieldId, callback)

Calls callback whenever event is triggered on the field with the given ID. If the ID refers to a container, the event listener is registered for all fields within the container.

form.ACTION(fieldId, ...)

There are quite a lot methods for manipulating form fields:

form.enable(fieldId)

Enables the form field.

form.disable(fieldId)

Disables the form field.

form.show(fieldId)

Shows the wrapping markup of the form field with the give ID.

form.hide(fieldId)

Shows the wrapping markup of the form field with the give ID.

form.fadeIn(fieldId)

Let's the wrapping markup of the form field with the give ID fade in.

form.fadeOut(fieldId)

Let's the wrapping markup of the form field with the give ID fade out.

form.slideDown(fieldId)

Let's the wrapping markup of the form field with the give ID slide down.

form.slideUp(fieldId)

Let's the wrapping markup of the form field with the give ID slide up.

form.addClass(fieldId, className)

Adds the given class to the wrapping markup of the form field with the given ID.

form.removeClass(fieldId, className)

Removes the given class from the wrapping markup of the form field with the given ID.

form.toggleClass(fieldId, className)

Toggles the given class of the wrapping markup of the form field with the given ID.

form.collapse(fieldId, action)

Processes an action on the content of the collapsable container with the given ID: show|hide|toggle.

form.showCollapse(fieldId)

Shows the content of the collapsable container with the given ID.

form.hideCollapse(fieldId)

Hides the content of the collapsable container with the given ID.

form.toggleCollapse(fieldId)

Toggles the content of the collapsable container with the given ID.

form.required(fieldId, action)

Processes an action on the required state of the field with the given ID: set|unset|toggle Handles the required attribute as well as the surrounding markup. Note: This is only happening client-sided. The sever-side validation is not affected.

form.setRequired(fieldId)

Sets the required state of the field with the given ID.

form.unsetRequired(fieldId)

Unsets the required state of the field with the given ID.

form.toggleRequired(fieldId)

Toggles the required state of the field with given ID.

form.readonly(fieldId, action)

Processes an action on the readonly state of the field with the given ID: set|unset|toggle

form.setReadonly(fieldId)

Sets the readonly state of the field with the given ID.

form.unsetReadonly(fieldId)

Unsets the readonly state of the field with the given ID.

form.toggleReadonly(fieldId)

Toggles the readonly state of the field with the given ID.

form.checked(fieldId, action)

Processes an action on the checked state of the (checkbox) field with the given ID: set|unset|toggle

form.setChecked(fieldId)

Sets the checked state of the (checkbox) field with the given ID.

form.unsetChecked(fieldId)

Unsets the checked state of the (checkbox) field with the given ID.

form.toggleChecked(fieldId)

Toggles the checked state of the (checkbox) field with the given ID.

form.if()

Returns a conditioned object for command chains. It will trigger its commands on any change of the condition evaluation. What is triggered depends on the following chain. The condition is also initially evaluated once and may trigger the chain according to the evaluation (without a field having changed its value). In that case, an extra parameter skipAnimation is set, to indicate that every show/hide/move should be done immediately.

Conditions

There are multiple types of conditions which can be used in the if-statement.

.if(condition, fieldId)

The condition is evaluated via the method form.eval(). Evaluation is triggered whenever the given field changes.

.if(fnc, fieldId)

The function fnc is called to do a custom evaluation. The evaluation is triggered whenever the given field changes.

.if(fnc)

The function fnc is called to do a custom evaluation. The evaluation is not triggered automatically. It either has to be triggered manually at a later point, or there need to be other conditions in the chain which trigger an evaluation.

.if(fieldId)

There is no evaluation added, but the evaluation is triggered when the given field changes. Other conditions would need ot be added. Otherwise the command chain will be triggered on every evaluation.

Condition Chaining

Conditions can be concatenated as DNF (disjunctive normal form) by using the following methods.

.and(), .or(), .openBracket(), .closeBracket()

Examples:

Condition Chaining Shortcuts

In order to avoid long command chains, each junction can be used for the next condition as well.

Also, all open brackets will be closed automatically when applying a command to the chain:

Query Nesting

It is possible to use one if-query as condition in another if-query. The nested query will be treated as a separate term, enclosed in brackets.

Notice that only the conditions are being evaluated in the parent query, not the resulting actions. In this example the action abc() will not be triggered by the second query.

Also notice that the triggers of the sub query are passed to the parent. In this example the second action def() will also be evaluated when text-1 or text-2 changes.

The equivalent without nesting would be like this:

Commands: Callback Methods

One way of adding commands is to use simple callback methods.

.call(callback)

The function callback will be called whenever the evaluation changes.

.then(callback)

The function callback will be called when ever the evaluation changes from false to true.

.else(callback)

The function callback will be called when ever the evaluation changes from true to false.

.once(callback)

The function callback will be called when the evaluation changes from false to true for the first time.

Commands: Intelligent Actions

A more comfortable way of adding triggers is to use intelligent actions. Those actions have to be known to the form object. You can also add a comma-separated list of actions, though you should be careful about actions which need additional parameters since all actions will have the same parameters passed. As far as possible, it will execute negated actions (show - hide, enable - disable, and so on) if the evaluation does not correspond with the trigger. Initially the actions will apply their changes without animations.

.then(action, fieldId, ...)

Executes the given form action whenever the evaluation changes from false to true. If the evaluation changes from true to false it will try to execute the negated action if known.

.onlyThen(action, fieldId, ...)

This action does the same as then but it will not try to execute the negated action if the evaluation does not match.

.else(action, fieldId, ...)

Executes the given form action whenever the evaluation changes from true to false. If the evaluation changes from false to true it will try to execute the negated action if known.

.onlyElse(action, fieldId, ...)

This action does the same as else but it will not try to execute the negated action if the evaluation does not match.

.once(action, fieldId, ...)

Executes the given form action when the evaluation changes from false to true for the first time. If the evaluation changes from true to false it will try to execute the negated action if known and if the evaluation hasn't changed from false to true, yet.

.then()

Stores the decision to execute any action on the form object directly by calling it on the query object.

The stored decision defaults to this behaviour, so you can skip right to the actions unless you used an .else() before.

.else()

Stored the decision to execute any action on the form object directly, but negated, by calling it on the query object.

The methods .then() and .else() can be combined in any order and with any signature.

Signature


All versions of form-logic with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
typo3/cms-core Version ^12.4 || ^13.4 || ^14.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mediatis/form-logic contains the following files

Loading the files please wait ...