diff options
Diffstat (limited to 'public/app/controllers/Office.php')
| -rw-r--r-- | public/app/controllers/Office.php | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/public/app/controllers/Office.php b/public/app/controllers/Office.php index 9eb2a4c..5038200 100644 --- a/public/app/controllers/Office.php +++ b/public/app/controllers/Office.php @@ -160,6 +160,9 @@ class Office { } + /** render application form + * + */ private static function render_application_form($opts) { // #1: user-id --------------------------------------------------------- @@ -170,15 +173,30 @@ class Office { // #3: inject default values ------------------------------------------- + $userData = Auth::user_data(); + // #3.1: inject user data $form_setup->defaults = json_decode( json_encode( - Auth::user_data(), JSON_UNESCAPED_UNICODE + $userData, JSON_UNESCAPED_UNICODE )); + // #3.2 inject `sector` and `position` <option>s + for($i=0; $i < sizeof($form_setup->form) ; $i++) { // get key-IDs + if (isset($form_setup->form[$i]->name)) { + if ($form_setup->form[$i]->name == 'sector') { $keySector = $i; } + if ($form_setup->form[$i]->name == 'position') { $keyPosition = $i; } + } + } + $form_setup->form[$keySector]->options = TEACHER_SECTORS; + $form_setup->form[$keyPosition]->options = ($userData['prefix'] == 'η') + ? GENDERED_POSITIONS['she'] + : GENDERED_POSITIONS['he']; + + // #4: get Form's HTML and Javascript ---------------------------------- $form = JsonToForm::json_form($form_setup, [ - ['name' => 'user_id', 'value' => $user_id] // pass user identity + ['name' => 'user_id', 'value' => $user_id] // pass user identity ]); // #5: render the view ------------------------------------------------- @@ -209,7 +227,7 @@ class Office { $teachers[] = $person['TeacherName']; } - // #3.2: get $key of rapporteur, president and members <select>s + // #3.2: get $key of `rapporteur`, `president` and `members` <select>s for($i=0; $i < sizeof($form_setup->form) ; $i++) { if (isset($form_setup->form[$i]->name)) { if ($form_setup->form[$i]->name == 'rapporteur') { $keyRapporteur = $i; } |
