This class controls all form rendering and basic form data i/o. It works independent of any data storage, getting its defaults from some external controlling instance in the form of a type array (f.x. a datamanager class can provide this). The list of types is taken by-reference.
The form rendering is done using the widgets and is based on HTML_QuickForm.
package | midcom.helper.datamanager2 |
---|
\midcom_helper_datamanager2_schema
&$schema The schema to use for processing. This
variable is taken by reference.array
&$types A list of types matching the passed schema, used as a basis for the
form types. This variable is taken by reference.see | \midcom_helper_datamanager2_schema::translate_schema_string() |
---|
string
The string to be translated.string
The translated string.Validation is only checked when save/next has been clicked; if it fails, the exitcode reverts to 'edit'.
string
One of 'editing', 'save', 'next', 'previous' and 'cancel'It must be a valid renderer name of the renderers defined in the renderer subdirectory of this component. The file loaded is renderer/$name.php, while the class instance created is midcom_helper_datamanager2_renderer_{$name}. The class must be default constructible and will be available in the renderer member of this class.
If name is 'none', no renderer instance is created, instead the default QuickForm Renderer is activated.
You cannot create custom renderer instances with this function, you need to create the instance manually and set it using set_renderer().
string
The renderer to createtodo | Make this better customizable |
---|---|
todo | Factor this out into a separate class This function should be deprecated. |
array
the submitted values.string
The field to queryThis is not done during the constructor call, to allow for full reference safety.
todo | Refactor into subfunctions for better readability. |
---|
mixed
The name of the form. This defaults to the name of the currently active component, which should
suffice in most cases.boolean
Indicating success.It will process the form results, if applicable, and return an according exit code.
This indicates which (if any) submit button was pressed. If 'editing' is returned, this means that either there was not data submitted yet, or that form validation has failed.
//This call ensures that MidCOM runs uncached.
string
One of 'editing', 'save', 'next', 'previous' and 'cancel'mixed
&$renderer A prepared HTML_QuickForm_Renderer (or subclass thereof) instance.string
the form field namestring
the new value to setstring
The name of the widget.array
Widget configuration.True
when widget is frozen, false otherwiseThis is called during the initialize code and will make the renderer available immediately after startup.
Ends the requested amount of fieldsets when 'end_fieldset' key is defined in the schema field or at least once when the key exists in the field.
string
array
Fieldsets can be initialized
by key start_fieldset
see | \midcom_helper_datamanager2_schema |
---|
string
array
This variable will always contain a parsed representation of the schema, so that one can swiftly switch between individual schemas of the Database.
access | protected |
---|
They must match the schemadb passed to the class.
The member is initialized by-reference.
access | protected |
---|
This member is set during the initialize call.
This value is to be considered read only.
This is the Namespace to use for all HTML/CSS/JS elements. It is deduced by the formmanager and tries to be as smart as possible to work safely with more then one form on a page.
You have to prefix all elements which must be unique using this string (it includes a trailing underscore).
It is set using the set_renderer() or create_renderer() calls.
If the configuration option 'default_renderer' (and possibly 'default_renderer_src') are set, the class will create instances of these renderers during startup, so that site users can directly use these defaults without further work. The following rules are used when determining which renderer to use:
If the default_renderer_src config option is null (the default), the class assumes that a default MidCOM renderer from the renderer subdirectory of this component should be used. In this case, you set only the actual renderer name (e.g. "simple") in default_renderer.
On the other hand, if you set the default_renderer_src option, the system first loads the snippet identified by that config option. the default_renderer option then has to hold the name of the renderer class that should be created. It must be default constructible.
If you don't want any renderer to kick in, set the (default) renderer to 'none' will stick to the QF Default renderer.
Authors note: Be aware that on the long run this rendering system will get some base classes which make building renderers with MidCOM support easier. Right now we simply use the standard run-of-the-mill renderers of QF, but be prepared that the API of this might change a bit (reflected in that new base class) on the long run.
This will be used to close the same amount to prevent open fieldset tags