Donate Share

Pieforms

File Release Notes and Changelog

Release Name: Pieforms 0.2.0

Notes:
AJAX forms
----------

Are now sent via a hidden iframe instead of a MochiKit JSONDoc call. This
means:

  - Files can be sent via js - any number of files per form
  - There's no need for the pieform_get_value_js_* functions anymore - the form
    is simply retargeted to the iframe so the browser does it automatically.

Are now enabled with 'jsform', NOT 'ajaxpost' (renamed as it can be sent by GET
or POST, and isn't AJAX anymore).

ajaxsuccessfunction and ajaxfailurefunction have been renamed to
jssuccesscallback and jserrorcallback for consistency

You can cancel from a js form.

Pieform class API changes
-------------------------

Most of the get_* methods are gone, replaced with get_property('propname') -
for example, get_method is now get_property('method')

Element API changes
-------------------

All element functions are now named pieform_element_*

So pieform_render_* becomes pieform_element_*
pieform_get_value_* becomes pieform_element_*_get_value

Checkboxes now use 'defaultvalue' instead of 'checked' to signal whether they
are on or off.

All functions that need the Pieform object now take it as their first argument!
This is a very large change, but makes things a lot more consistent.

'ajaxmessages' flag has been renamed to 'submitelement', as that's more
descriptive

i18n
----

Now each element, renderer and rule can define their own i18n strings.
Individual elements in a form can set the 'rulei18n' index to customise the
i18n string for their own rules, and forms can set the 'rule18n' index to pass
in defaults for the whole form. Because of the last one, pieform_configure can
be used to pass default strings to all forms.

Rules
-----

Now each element can define a function that describes how a rule applies to it.
This is useful for, say, the WYSIWYG element: we can say that
trim(strip_tags($value)) is the test for 'required'.

Fixes
-----

  * Tabindex fixed for calendar and date elements
  * Hopefully now checkboxes are not completely retarded in their behaviour when
    form is/is not submitted
  * Select elements won't die horribly if they have no options
  * All submit type element send their values through only when submitted,
    without actually killing the value when they are displayed
  * Table renderer sets 'error' class on elements correctly when an error
    occurs on AJAX post, and removes it again if the element no longer has an
    error on it.
  * You can now have a presubmit function for a non js form

Enhancements
------------

Fieldsets can be collapsed
Textareas can be resized

There's various other changes too, more than can be documented here. But this
is a development release with no documentation, so instead of trying to list
them all, I will write some documentation :)


Changes: ------------------------------------------------------------------------ r71 | oracleshinoda | 2006-11-29 12:14:35 +1300 (Wed, 29 Nov 2006) | 1 line Many fixes to the date element, allowing it to be optionally unset. It now takes its value as a unix timestamp as well as returning it that way ------------------------------------------------------------------------ r72 | oracleshinoda | 2006-11-29 12:22:36 +1300 (Wed, 29 Nov 2006) | 1 line Hopefully added support for different callbacks based on the name of the submit button pressed ------------------------------------------------------------------------ r73 | oracleshinoda | 2006-11-29 15:55:14 +1300 (Wed, 29 Nov 2006) | 1 line Fix up obvious fuckups, remove restriction on needing to define the default submit function ------------------------------------------------------------------------ r74 | oracleshinoda | 2006-12-01 14:04:30 +1300 (Fri, 01 Dec 2006) | 1 line Improved the email validation rule somewhat ------------------------------------------------------------------------ r75 | oracleshinoda | 2006-12-06 22:21:00 +1300 (Wed, 06 Dec 2006) | 1 line Honour 'required' => false correctly (Alastair Pharo) ------------------------------------------------------------------------ r76 | oracleshinoda | 2006-12-07 11:01:14 +1300 (Thu, 07 Dec 2006) | 1 line Added a 'oneline' renderer - renders each element in a span. No error reporting or contextual help though ------------------------------------------------------------------------ r77 | oracleshinoda | 2006-12-07 11:02:27 +1300 (Thu, 07 Dec 2006) | 1 line Added an image element, for input type='image' buttons. ------------------------------------------------------------------------ r78 | oracleshinoda | 2006-12-07 18:32:18 +1300 (Thu, 07 Dec 2006) | 1 line Make each element have their ID prefixed by the form name, which is safer when more than one form is on a page ------------------------------------------------------------------------ r79 | oracleshinoda | 2006-12-07 18:34:36 +1300 (Thu, 07 Dec 2006) | 1 line The element_attributes method is now part of the class instead of static, so it can add it's own name to the ID for an element ------------------------------------------------------------------------ r80 | oracleshinoda | 2006-12-07 18:36:09 +1300 (Thu, 07 Dec 2006) | 1 line The element_attributes method is now part of the class instead of static, so it can add it's own name to the ID for an element ------------------------------------------------------------------------ r81 | oracleshinoda | 2006-12-07 18:39:15 +1300 (Thu, 07 Dec 2006) | 1 line The element_attributes method is now part of the class instead of static, so it can add it's own name to the ID for an element ------------------------------------------------------------------------ r82 | oracleshinoda | 2006-12-07 18:41:51 +1300 (Thu, 07 Dec 2006) | 1 line The element_attributes method is now part of the class instead of static, so it can add it's own name to the ID for an element ------------------------------------------------------------------------ r83 | oracleshinoda | 2006-12-07 18:43:30 +1300 (Thu, 07 Dec 2006) | 1 line Did one of the TODO items - use MochiKit's connect() to handle the form submission. Made sure that elements have their 'id' attribute have the form name put on the front, so more than one form can be used on the same page successfully. ------------------------------------------------------------------------ r84 | oracleshinoda | 2006-12-08 15:09:46 +1300 (Fri, 08 Dec 2006) | 1 line Standardised how plugins are included ------------------------------------------------------------------------ r85 | oracleshinoda | 2006-12-08 15:11:55 +1300 (Fri, 08 Dec 2006) | 1 line Standardised how plugins are included ------------------------------------------------------------------------ r86 | oracleshinoda | 2006-12-08 15:12:45 +1300 (Fri, 08 Dec 2006) | 1 line Removed wysiwyg element, it will come back as 'tinymce' element at some point ------------------------------------------------------------------------ r87 | oracleshinoda | 2006-12-10 23:54:31 +1300 (Sun, 10 Dec 2006) | 1 line Calendar element. Provides a date/time picker using a javascript calendar ------------------------------------------------------------------------ r88 | oracleshinoda | 2006-12-10 23:56:51 +1300 (Sun, 10 Dec 2006) | 1 line Fixed label for radio elements ------------------------------------------------------------------------ r89 | oracleshinoda | 2006-12-10 23:57:41 +1300 (Sun, 10 Dec 2006) | 1 line Fixed HTML validity when using 'disabled' attribute. Added a couple of TODO items ------------------------------------------------------------------------ r90 | oracleshinoda | 2006-12-10 23:59:26 +1300 (Sun, 10 Dec 2006) | 1 line Allowed each element to specify a function that returns an array of HTML items that should be used to set the object up. Useful for calendar/wysiwyg. Also allowed the user to define a function to configure the default form of any element type. ------------------------------------------------------------------------ r91 | oracleshinoda | 2006-12-11 00:00:43 +1300 (Mon, 11 Dec 2006) | 1 line Added javascript for calendar ------------------------------------------------------------------------ r92 | oracleshinoda | 2006-12-11 00:06:17 +1300 (Mon, 11 Dec 2006) | 1 line Added licensing information about the jscalendar ------------------------------------------------------------------------ r93 | oracleshinoda | 2006-12-15 14:25:13 +1300 (Fri, 15 Dec 2006) | 1 line Namespace the renderer IDs properly ------------------------------------------------------------------------ r94 | oracleshinoda | 2006-12-15 14:25:45 +1300 (Fri, 15 Dec 2006) | 1 line Namespace the renderer IDs properly ------------------------------------------------------------------------ r95 | oracleshinoda | 2006-12-15 14:26:25 +1300 (Fri, 15 Dec 2006) | 1 line Namespace the message element for ajax messages properly ------------------------------------------------------------------------ r96 | oracleshinoda | 2006-12-15 14:27:49 +1300 (Fri, 15 Dec 2006) | 1 line Made the calendar element deal in unix timestamps (Martyn Smith) ------------------------------------------------------------------------ r97 | oracleshinoda | 2006-12-15 14:28:52 +1300 (Fri, 15 Dec 2006) | 1 line Temporary fix for tabindex for expiry elements ------------------------------------------------------------------------ r98 | oracleshinoda | 2006-12-15 14:30:15 +1300 (Fri, 15 Dec 2006) | 1 line Fixed support for multiple submit buttons with their own function (Alastair Pharo) ------------------------------------------------------------------------ r99 | oracleshinoda | 2006-12-18 12:24:49 +1300 (Mon, 18 Dec 2006) | 1 line Be much smarter about which submit button is being sent through in ajax land. This prevents problems with all buttons being sent through and thus causing hiccups with the choice of submit function to call. It also conveniently makes sure that the status messages will always be displayed next to the correct button ------------------------------------------------------------------------ r100 | oracleshinoda | 2006-12-18 12:26:45 +1300 (Mon, 18 Dec 2006) | 1 line Use the new, smarter way of putting messages next to the correct submit button. Also, use some of the nicer new MochiKit methods to insert divs before/after others ------------------------------------------------------------------------ r101 | oracleshinoda | 2006-12-18 12:27:39 +1300 (Mon, 18 Dec 2006) | 1 line Use the new, smarter way of putting a message next to the correct submit button ------------------------------------------------------------------------ r102 | oracleshinoda | 2006-12-18 13:41:26 +1300 (Mon, 18 Dec 2006) | 1 line Allowed the form tag to be retrieved separately from the rest of the form, which allows more flexibility in how the form is built. Hopefully fix up the passing of the submit value for ajax calls now as well ------------------------------------------------------------------------ r103 | oracleshinoda | 2006-12-18 14:11:25 +1300 (Mon, 18 Dec 2006) | 1 line Actually make multiplebutton ajax submit work reasonably well now... ------------------------------------------------------------------------ r104 | oracleshinoda | 2006-12-18 14:12:20 +1300 (Mon, 18 Dec 2006) | 1 line Make sure the multicolumntable renderer doesn't try to pass on nonexistant values ------------------------------------------------------------------------ r105 | oracleshinoda | 2006-12-23 16:36:11 +1300 (Sat, 23 Dec 2006) | 27 lines * Updated the comment on the Pieform class to better reflect the API changes being made * Only include the JSON library when json_encode is first called * Moved all of the user-configurable flags for the class into one member variable, 'data'. * Renamed the ajaxsuccessfunction and ajaxfailurefunction to *callback for consistency * Made the cancel function optional * Made setting $element['goto'] actually work, for both normal forms and AJAX forms * Fixed all submit-based elements to have their value placed in the submit data if they are pressed. * AJAX submission is now no longer strictly AJAX - instead, data is submitted to a hidden iframe. This removes all of the mess around the pieform_get_value_js_[element] functions, and allows sending files (which works fine, even for more than one file). * Now all replies by JSON should be done using the $form->json_reply method, which understands how to reply to a hidden iframe. * Defined some constants for use with $form->json_reply * Full i18n is now built in. Each element can export its own strings, and the user can override them on a per element or per form basis (even for all forms in their application with the pieform_configure function). * API changes: - Renamed pieform_configure_[element] to pieform_element_[element]_configure - Submit functions now take the Pieform object as their first parameter (major BC break!) - pieform_render_element now takes its parameters in reverse order (although this function is largely an internal-only function) - Renamed pieform_get_value_[element] to pieform_element_[element]_get_value - Renamed pieform_render_[element] to pieform_element_[element] (major BC break!) - pieform_element_[element] functions now takes the Pieform object as their first parameter (major BC break!) ------------------------------------------------------------------------ r106 | oracleshinoda | 2006-12-23 16:39:29 +1300 (Sat, 23 Dec 2006) | 1 line Made the tablerenderer work again with the changes made recently. It now also correctly sets the error class on elements have an error on them ------------------------------------------------------------------------ r107 | oracleshinoda | 2006-12-23 16:44:21 +1300 (Sat, 23 Dec 2006) | 1 line Use new i18n API for regex rule ------------------------------------------------------------------------ r108 | oracleshinoda | 2006-12-23 16:46:16 +1300 (Sat, 23 Dec 2006) | 1 line Use new i18n API for integer rule ------------------------------------------------------------------------ r109 | oracleshinoda | 2006-12-23 16:47:04 +1300 (Sat, 23 Dec 2006) | 1 line Use new i18n API for required rule ------------------------------------------------------------------------ r110 | oracleshinoda | 2006-12-23 16:48:02 +1300 (Sat, 23 Dec 2006) | 2 lines Updated all rules to use the new i18n api ------------------------------------------------------------------------ r111 | oracleshinoda | 2006-12-23 16:48:43 +1300 (Sat, 23 Dec 2006) | 1 line Updated hidden element for new API ------------------------------------------------------------------------ r112 | oracleshinoda | 2006-12-23 16:50:31 +1300 (Sat, 23 Dec 2006) | 1 line Updated elements to new API ------------------------------------------------------------------------ r113 | oracleshinoda | 2006-12-23 16:54:18 +1300 (Sat, 23 Dec 2006) | 1 line Updated elements to new API ------------------------------------------------------------------------ r114 | oracleshinoda | 2006-12-23 16:56:23 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use the new API. Also correctly prevent focus from applying to them ------------------------------------------------------------------------ r115 | oracleshinoda | 2006-12-23 16:57:27 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use the new API. Corrected tabindex too. ------------------------------------------------------------------------ r116 | oracleshinoda | 2006-12-23 17:01:31 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use the new API. Furthermore, now correctly returns its value when it has been used for submission ------------------------------------------------------------------------ r117 | oracleshinoda | 2006-12-23 17:03:12 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use the new API ------------------------------------------------------------------------ r118 | oracleshinoda | 2006-12-23 17:04:11 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use the new APIs. The 'optional' flag is now gone, replaced with responding to the 'required' rule, which makes much more sense ------------------------------------------------------------------------ r119 | oracleshinoda | 2006-12-23 17:04:50 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use the new APIs. Use Pieform::info so that people can acutally use it ------------------------------------------------------------------------ r120 | oracleshinoda | 2006-12-23 17:05:37 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use the new API. Removed done TODOs ------------------------------------------------------------------------ r121 | oracleshinoda | 2006-12-23 17:06:32 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use the new APIs. Use Pieform::info so that people can acutally use it ------------------------------------------------------------------------ r122 | oracleshinoda | 2006-12-23 17:07:30 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use the new APIs. Also behaves better when the required rule is set ------------------------------------------------------------------------ r123 | oracleshinoda | 2006-12-23 17:08:19 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use the new APIs. Now passes its value through correctly if it is used for submission. ------------------------------------------------------------------------ r124 | oracleshinoda | 2006-12-23 17:09:15 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use new APIs. ------------------------------------------------------------------------ r125 | oracleshinoda | 2006-12-23 17:09:58 +1300 (Sat, 23 Dec 2006) | 1 line Updated to use new APIs. Now responds to 'defaultvalue' instead of 'checked', like most other elements ------------------------------------------------------------------------ r126 | oracleshinoda | 2006-12-23 17:35:31 +1300 (Sat, 23 Dec 2006) | 1 line Renamed the 'ajaxmessages' flag to 'submitelement', as it's used for more than just where to put ajax submit messages ------------------------------------------------------------------------ r127 | oracleshinoda | 2006-12-23 18:03:37 +1300 (Sat, 23 Dec 2006) | 1 line Added a new flag, 'cancelelement', so that erraneous javascript is not added for them, and their value can still be quashed when the post data is sent. Also, allow elements to specify a function that describes how a rule applies to them, which can be very useful when the way that the rule works is 'almost' right, but you don't want to make a new rule ------------------------------------------------------------------------ r128 | oracleshinoda | 2006-12-23 18:05:49 +1300 (Sat, 23 Dec 2006) | 1 line pieform_is_empty_file is not needed anymore, the get_value stuff has been doing this for a while so the 'required' rule is behaving correctly ------------------------------------------------------------------------ r129 | oracleshinoda | 2006-12-23 18:06:21 +1300 (Sat, 23 Dec 2006) | 1 line Cancel element now identifies itself as such ------------------------------------------------------------------------ r130 | oracleshinoda | 2006-12-23 18:07:25 +1300 (Sat, 23 Dec 2006) | 1 line Removed the references to form_is_empty_ in the required rule, there's a more generic way to do this now ------------------------------------------------------------------------ r131 | oracleshinoda | 2006-12-23 18:09:20 +1300 (Sat, 23 Dec 2006) | 1 line Fix silly parse error ------------------------------------------------------------------------ r132 | oracleshinoda | 2006-12-23 18:10:44 +1300 (Sat, 23 Dec 2006) | 1 line Make sure the 'error' class is removed from elements when all errors are being removed ------------------------------------------------------------------------ r133 | oracleshinoda | 2006-12-23 18:13:18 +1300 (Sat, 23 Dec 2006) | 1 line Removed mahara-isms that would have prevented anyone else from using it from svnhead ------------------------------------------------------------------------ r134 | oracleshinoda | 2006-12-24 02:13:02 +1300 (Sun, 24 Dec 2006) | 1 line Removed the messages functions, they are no longer needed. The function itself will later be renamed ------------------------------------------------------------------------ r135 | oracleshinoda | 2006-12-24 02:23:23 +1300 (Sun, 24 Dec 2006) | 11 lines * You can now have a javascript presubmit function non javascript forms. * A bunch of the callbacks have had their names changed for yet more consistency. * Forms that use a hidden iframe to submit to are now known as 'javascript forms' or 'jsforms', not AJAX forms, because they're not using AJAX. A bunch of the callbacks have been renamed based on this. * Support has been added for a PHP callback if a form fails to validate, and a javascript callback if the returnCode is not recognised. * Some function calls were changed to use call_user_func_array, which allows the possibility that they're not just strings (i.e. they could be class/method array pairs) * Reduced the number of parameters for json_reply to two, now the 'errors' index of the 'message' data holds any errors specific to form elements. * The errors sent back will now be set for any nonzero return code. * Broke out the javascript for detecting which button was pressed last into its own method. * Unset the detected last pressed submit button just before the form callback finishes, which prevents randomness when pressing cancel buttons later * Made the get_errors method public, someone else may want access to it. ------------------------------------------------------------------------ r136 | oracleshinoda | 2006-12-24 13:18:11 +1300 (Sun, 24 Dec 2006) | 1 line Updated the div javascript for the recent changes made ------------------------------------------------------------------------ r137 | oracleshinoda | 2006-12-24 13:19:12 +1300 (Sun, 24 Dec 2006) | 1 line Slight improvements to the javascript for the table renderer ------------------------------------------------------------------------ r138 | oracleshinoda | 2006-12-24 13:20:47 +1300 (Sun, 24 Dec 2006) | 1 line Updated the expiry element to work with the error javascript stuff. ------------------------------------------------------------------------ r139 | oracleshinoda | 2006-12-24 13:23:51 +1300 (Sun, 24 Dec 2006) | 1 line Ignore vim .swp files ------------------------------------------------------------------------ r140 | oracleshinoda | 2006-12-24 13:25:05 +1300 (Sun, 24 Dec 2006) | 1 line Ignore vim .swp files ------------------------------------------------------------------------ r141 | oracleshinoda | 2006-12-24 15:32:29 +1300 (Sun, 24 Dec 2006) | 1 line Insert empty table cells in gaps to preserve HTML validation. Disable fieldsets from working, they just make a mess. Fixed up the javascript for inserting errors so it actually works ------------------------------------------------------------------------ r142 | oracleshinoda | 2006-12-24 18:12:32 +1300 (Sun, 24 Dec 2006) | 1 line Renamed the *_messages_js functions to *_get_js, which is more appropriate ------------------------------------------------------------------------ r143 | oracleshinoda | 2006-12-24 19:29:24 +1300 (Sun, 24 Dec 2006) | 1 line Renumbered response constants to be negative numbers, to allow application developers to use the positive numbers ------------------------------------------------------------------------ r144 | oracleshinoda | 2006-12-26 12:45:25 +1300 (Tue, 26 Dec 2006) | 1 line Forms will now die if execution is continuing after the submit function is called, however this behaviour can be turned off if necessary (the transient login page in Mahara requires it to be off) ------------------------------------------------------------------------ r145 | oracleshinoda | 2006-12-26 13:18:04 +1300 (Tue, 26 Dec 2006) | 1 line Moved js/ to static/, as CSS, images and other things may find their way into that directory ------------------------------------------------------------------------ r146 | oracleshinoda | 2006-12-26 13:27:24 +1300 (Tue, 26 Dec 2006) | 1 line Moved js/ to static/ ------------------------------------------------------------------------ r147 | oracleshinoda | 2006-12-26 13:28:16 +1300 (Tue, 26 Dec 2006) | 1 line Moved MochiKit stuff to the core/ directory ------------------------------------------------------------------------ r148 | oracleshinoda | 2006-12-27 17:58:00 +1300 (Wed, 27 Dec 2006) | 1 line Loosened the check for fieldsets a little bit so that classes can be added to the fieldset. Required for collapsable fieldset support ------------------------------------------------------------------------ r149 | oracleshinoda | 2006-12-27 18:27:58 +1300 (Wed, 27 Dec 2006) | 1 line Added support for 'collapsable' fieldsets (doesn't depend on 'jsform'). Listens to 'collapsable' and 'collapsed' options. If there is an error with form submission in a collapsed fieldset it is expanded. ------------------------------------------------------------------------ r150 | oracleshinoda | 2006-12-27 18:37:33 +1300 (Wed, 27 Dec 2006) | 1 line Removed some comments from the javascript output for jsform submissions, comments aren't needed (later on this stuff might be packed). Added a bit of code to handle expanding a fieldset if it contains elements with errors in them. ------------------------------------------------------------------------ r151 | oracleshinoda | 2006-12-27 18:38:39 +1300 (Wed, 27 Dec 2006) | 1 line Ignore .swp files ------------------------------------------------------------------------ r152 | oracleshinoda | 2006-12-27 19:23:15 +1300 (Wed, 27 Dec 2006) | 1 line Added tabindex to fieldset for keyboard navigation ------------------------------------------------------------------------ r153 | oracleshinoda | 2006-12-27 22:09:43 +1300 (Wed, 27 Dec 2006) | 1 line Add 'class=pieform' to all pieforms, so they can be targetted by javascript routines. Add a class of 'resizable' to textareas if needed, so javascript can target them ------------------------------------------------------------------------ r154 | oracleshinoda | 2006-12-27 22:12:04 +1300 (Wed, 27 Dec 2006) | 1 line Added pieforms.js, which will contain pieforms-specific javascript. Currently includes support for resizable textareas ------------------------------------------------------------------------ r155 | oracleshinoda | 2006-12-28 01:49:27 +1300 (Thu, 28 Dec 2006) | 1 line Changed the i18n function name for the email rule to be correct ------------------------------------------------------------------------ r156 | oracleshinoda | 2006-12-28 01:54:07 +1300 (Thu, 28 Dec 2006) | 1 line Allow forms to specify an error message for jsforms. This is a small helper that stops the need to define a _error function if you want to send an error back. The message is completely optional ------------------------------------------------------------------------ r157 | oracleshinoda | 2007-01-02 14:17:32 +1300 (Tue, 02 Jan 2007) | 1 line Updated documentation for 0.2 release ------------------------------------------------------------------------ r158 | oracleshinoda | 2007-01-02 14:23:28 +1300 (Tue, 02 Jan 2007) | 1 line Added a changelog file ------------------------------------------------------------------------