What are scripts and pieces? I have seen them in the advanced form settings but I have no idea what they do.

Scripts and Pieces are the places to use if you need to add some custom functionality to your form. Developers can easily use those sections to add his Javascript and/or PHP.

Scripts Tab

==> Initialization Script: A javascript that should be executed on form initalization (=loading)
==> Submitted Script: A javascript that will be triggered after the form has been submitted.

Form Pieces Tab

==> Before Form: PHP that should be executed before the form is rendered. You can for example print something out and it will be displayed on top of the form.
==> After Form: The same like above but will be executed after the form is rendered. So printing will happen in the end of the form.

Submit Pieces Tab

==> Before Submit: PHP that will be executed before the form is going to be submitted. You can use this for example catching values and prevent storing a submission.
==> After Submit: Same like above, except that it will be executed after a submission has been stored.

*NOTE: Do not use opening PHP tags <?php in the pieces sections, else you will get errors!

 

All of these tabs above share the same concept:

- Library: You can choose a predefined script/piece from the library. While each item of the library can be packaged itself. Means, you can create your own library items and re-use them in other forms.

- Custom: You can add code directly in-place for one of the actions above. For custom scripts it is required that you click "create code framework" first in order to have a javascript function skeleton where you place your code into, while for pieces you can start writing your custom code without the need to create a function.

Things you always want to use in a Piece (PHP):

ff_getSubmit('FIELDNAME') => will return the value of a field
ff_getSubmit('FIELDNAME', FF_ARRAY) => will return the value of a field as array. Required if you want access to values of a group like a checkbox

As soon as you use things like ff_getSubmit() in your piece, put this as first command into your custom code:

 

$this -> execPieceByName('ff_InitLib');

 

Things you always want to use in a Script (Javascript):

ff_getElementByName('FIELDNAME') ==> will return the DOM object of the field
ff_getElementByName('FIELDNAME').value ==>will return the value of that field

The same is applicable for scripts that you use for validations, actions and initializations on field level.

Special Offer

Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!