Resizing Custom Fields


Custom fields and custom components are embedded in forms using IFrames. IFrames have their advantages (you won’t ruin your form by writing a custom element) but also their drawbacks. One of them is having to specify the frame width to avoid scroll bars.

To make custom element presentation easier for form developers, ActiveForms tries to automatically adjust the frame height to the height of the page rendered inside. When a page is fully loaded inside an IFrame (i.e. a custom element), the ActiveForms engine checks its height, and then updates the frame height.

Unfortunately, rendering a custom element page can take some time, and your user will see the frame with a default size first, and then (when the custom element is ready) the IFrame height will be adjusted and the scroll bars will disappear. You can avoid that by specifying the initial frame height in FormBuilder. If you specify the height in pixels in the Initial Height field, ActiveForms will not attempt to resize the frame.

Some custom elements are really worth their name and can change their size while the form is being completed. Imagine a custom field used for validating entered data on an external server in real time, and error information displayed immediately underneath. The displayed text can expand the frame and scroll bars can appear.

The solution is the ‘updateSize’ function provided by ActiveForms. Each epoint_activeforms_customField or epoint_activeforms_customComponent object has the updateSize(height) method. Calling the this.updateSize() method (with no parameters) in the custom element code will recalculate the IFrame height and make the scroll bars disappear. Calling this method with a height specified in the parameter (in pixels) will change the IFrame height to the specified value.

Use this method whenever you suspect that the size of a custom element may change. If you show and hide some text or messages, forcing a recalculation of the custom element size is a good idea.

recent posts
3rd Apr 2014
Faster than ever!
5th Dec 2013
Live validation!
2nd Dec 2013
Features distilled
12th Mar 2012
Flicking Channels
26th Jan 2012
Your Own Error Page
9th May 2011
Box Properties
15th Apr 2011
Grouping Fields
13th Apr 2011
Form Versioning
24th Feb 2011
Form Access Modes
22nd Feb 2011
Required Fields
4th Feb 2011