Skip to content

LORIS Form

Stella Lee edited this page Dec 20, 2016 · 30 revisions

under construction


As of LORIS 17.0 (late 2016), LorisForm will replace HTML QuickForm

How to update PHP QuickForm instruments to LorisForm

This section is ONLY for existing projects updating to Loris 17.0

Since LorisForm is designed to match HTML QuickForm, to update each of your instruments to LorisForm, remove/replace the following:

  • Replace Quickform references:
   $this->form = new HTML_Quickform('test_name');

and replace with this line:

    $this->form = new LorisForm('test_name');
  • Remove any further references to QuickForm such as:
    require_once 'HTML/QuickForm.php';
    require_once 'HTML/QuickForm/Renderer/Array.php';
  • Remove calls to registerRule() - this function is deprecated in LorisForm (excludes XINRegisterRule())

Date fields are now strings instead of arrays:

  • Replace addGroupRule() with addRule() (example), since date fields are now strings instead of arrays
  • Remove calls to addRule() using checkdate
       $this->addRule(		
           'Date_taken',		
           'Date of Administration is invalid',		
           'checkdate'		
       );

Multi-page instruments: check your _setupForm() function for this:

    $this->_page($matches[1])

and replace with this line:

    call_user_func(array($this, $matches[1]));

Element names need to be unique

  • Elements including groups and labels are required to have unique names in order to be displayed on the front end. Uniqueness is required within a single page of an instrument.

Other updates unrelated to LorisForm

Note on dependencies: Don't forget to run composer install --no-dev and then composer dump-autoload to update dependencies and re-generate the autoload.php file.

Database tables and data are otherwise unaffected by the switch to LorisForm.

For a few examples, see recent updates to sample instruments in the docs/instruments directory for 17.0.


About LorisForm

Loris Form permits specific element types to match those generated by the Instrument Builder:

  • dropdown select
  • multiselect
  • textbox (brief text answers)
  • text area
  • numerical
  • date
  • label
  • score columns (static for calculated values, not for data entry)

Note on Radio buttons and Checkboxes

Radio buttons and checkboxes are not allowed by Loris Form for a very important reason: distinguishing No from Not Answered in data entry responses is critical for statistical validity of clinical data.

  • A checkbox left blank doesn’t distinguish a No response from Not Answered (or Ignored)
  • Each individual radio button is treated by PHP as a separate form element and so would require a separate database field for every valid response to a single question. For binary (yes/no) questions, a select-dropdown (options: yes/no/NotAnswered) is still preferable anyway, in order to distinguish No from Not Answered.
Clone this wiki locally