The form field filter system
Login / Search
#40750 (In Topic #9090)
(I should be clear about this being a feature for power-users. It's intentionally buried deep within the guts of the system and I don't want anyone to feel they need to understand or use this to make a site in ocPortal)
The form field filter system
ocPortal provides an advanced feature for manipulating forms and the results of forms using filters without having to change the PHP code. By the end of this tutorial you will understand the enormous power this can give you.
This features are intended for power-users, using an XML config file for defining the filters.
The form field filter system can influence both form results, and the default values displayed within form fields.
The config file structureThe config file is data_custom/fields.xml. You will see there are some default settings in that file, which are designed to be fairly innocuous. You should review the default settings as examples.
The root XML tag for the config file is 'fieldRestrictions'. Otherwise, the config file mostly consists of restriction tags. Restriction tags (explained later) can be placed directly beneath 'fieldRestrictions', but they may also be placed under the special 'qualify' and 'filter' tags. Furthermore, 'qualify' and 'filter' tags can be placed underneath themselves and each other to provide nestings of arbitrary complexity.
The 'qualify' and 'filter' tagsThe 'qualify' tag is used to limit the context under which restriction tags may apply. Without the 'qualify' tag, the restrictions would always apply.
The tag may take 3 attributes (all optional, but they may also be used together):
The 'filter' tag again is used to limit the situations under which restriction tags may apply, but it filters based on membership rather than context. The tag may take 3 attributes (all optional, but they may also be used together):
Restriction tagsThe following restriction tags are supported for manipulating form results:
You may give each of these restriction tags an 'error' attribute, which will be used for the case when they trigger. If you do not provide a message a default will be used based upon the restriction involved.
The following restriction tags are supported for manipulating form results, and also default form field values:
ExtensionThe form field filter system is ripe for extension by programmers. It would not be hard for a programmer to add new filter attributes. For example, a filter could be added to allow filtering based on day of the week, or geographic location. We'd love to see innovative ocPortal modifications written around this kind of functionality (e.g. a modification to "only allow people to submit a quiz on Halloween from an iPhone").
So many new OCP toys, so little time.
Thanx for typing that up Chris! I'm going to take a peak at it this weekend and see what fun we can have.
"no violence, no hate, no pain, no enemies
just peace, unity, tolerance and love" - The Beloved
OCP V7 | Advocating monetary reform - FreeOurMoney
Need OCP friendly hosting? Look no further:
Web Hosting, Reseller Hosting, and Dedicated Servers w/cPanel - Elief! - Official hosting partner for ocPortal.
There are too many online users to list.