GemsTracker

GEneric Medical Survey Tracker

User Tools

Site Tools


devzone:giftbox:changing_a_form_element

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
devzone:giftbox:changing_a_form_element [2012/11/27 17:01]
Roel created
devzone:giftbox:changing_a_form_element [2020/03/12 12:06] (current)
Line 2: Line 2:
  
 We will change the studynumber field from editable to non-editable,​ so you need to change a respondent details textbox.\\ We will change the studynumber field from editable to non-editable,​ so you need to change a respondent details textbox.\\
-First create your own respondent controller if you have not yet done so (see [[devzone:​howto|howto]]).\\+First create your own respondent controller if you have not yet done so (see [[devzone:​howto:start|howto]]).\\
 There is only one function you need to overrule: the addFormElements function. \\ There is only one function you need to overrule: the addFormElements function. \\
 First the parent class is used to create your form, then it gets the tab on which your element sits, and adds the same element again as Exhibitor element: First the parent class is used to create your form, then it gets the tab on which your element sits, and adds the same element again as Exhibitor element:
Line 23: Line 23:
         parent::​addFormElements($bridge,​ $model, $data, $new);         parent::​addFormElements($bridge,​ $model, $data, $new);
  
-        // show studynr non-editable+        // show studynr non-editable ​and add a validator at the same time 
 +        ​
         $bridge->​getTab('​caption1'​);​         $bridge->​getTab('​caption1'​);​
 +        // The simple version: ​       ​
         $bridge->​addExhibitor('​gr2o_patient_nr'​);​         $bridge->​addExhibitor('​gr2o_patient_nr'​);​
 +
 +        // The advanced option: add a validator as well
 +        /*
 +         * $bridge->​addExhibitor('​gr2o_patient_nr'​)
 +               ​->​addValidator( ​ $model->​createUniqueValidator(array('​gr2o_patient_nr',​ '​gr2o_id_organization'​),​ array('​gr2o_id_user'​ => '​grs_id_user',​ '​gr2o_id_organization'​)));​
 +        */
  
     }     }
 </​code>​ </​code>​
  
-This will replace the original element with the new layout.+This will replace the original element with the new layout. ​\\ 
 +In the advanced option, we added a validator that will check if the combination of patientnr and organizationid is unique (first array),  
 +excluding the current edited record (second array). \\ 
 +This might look confusing, but that's why it is an advanced option!
devzone/giftbox/changing_a_form_element.1354032090.txt.gz · Last modified: 2020/03/12 12:08 (external edit)