Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-43587

User Profile Form: Selected Custom Field data should not be processed through text filter before saving to database table

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • None
    • 2.5.2, 2.6, 2.7.10, 3.1.9, 3.2.6, 3.3.3, 3.4, 3.5, 3.6.5, 3.7.1, 3.8
    • Administration, Filters
    • MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • MDL-43587-master
    • Hide

      Prerequisites:

      • Ensure that multilang filter is enabled.
      • The following instructions assumes that your Moodle installation is setup to handle English and French language. You may need to change the languages in the strings to be inserted in order to accommodate the languages you have enabled on your test site.
      1. Login to Moodle as Administrator
      2. Click Home > Site Administration > Users > Account > User profile fields
      3. Create a new profile field of type "Dropdown menu"
      • Shortname: salutation
      • Name: Salutation
      • Menu options (one per line): Enter the following information:

      <span lang="en" class="multilang">Dr.</span><span lang="fr" class="multilang">Dr</span>
      <span lang="en" class="multilang">Mr.</span><span lang="fr" class="multilang">M</span>
      <span lang="en" class="multilang">Mrs.</span><span lang="fr" class="multilang">Mme</span>
      <span lang="en" class="multilang">Ms.</span><span lang="fr" class="multilang">Mlle</span>

      In the Default field, add the following string:

      <span lang="en" class="multilang">Mr.</span><span lang="fr" class="multilang">M</span>

      Save your changes.

      ____________________________________________
      Testing the Default field Value

      1. Edit your profile.
      2. Locate the new field Salutation field we just created.
      3. The default should be "Mr." or "M." depending on whether you are viewing the form in English or French. This indicates that the Default field value has an effect. Without this fix, "Dr." (the first value below "Choose...") would have been the default.

      ____________________________________________
      Testing Saving

      1. Change the Salutation field to something other than Dr. and save your change.
      2. You should now see your Salutation field displayed in your profile. Unlike before, the value of the salutation field will now correctly display in the French version when you switch the Moodle user interface language to French.
      Show
      Prerequisites: Ensure that multilang filter is enabled. The following instructions assumes that your Moodle installation is setup to handle English and French language. You may need to change the languages in the strings to be inserted in order to accommodate the languages you have enabled on your test site. Login to Moodle as Administrator Click Home > Site Administration > Users > Account > User profile fields Create a new profile field of type "Dropdown menu" Shortname: salutation Name: Salutation Menu options (one per line): Enter the following information: <span lang="en" class="multilang">Dr.</span><span lang="fr" class="multilang">Dr</span> <span lang="en" class="multilang">Mr.</span><span lang="fr" class="multilang">M</span> <span lang="en" class="multilang">Mrs.</span><span lang="fr" class="multilang">Mme</span> <span lang="en" class="multilang">Ms.</span><span lang="fr" class="multilang">Mlle</span> In the Default field, add the following string: <span lang="en" class="multilang">Mr.</span><span lang="fr" class="multilang">M</span> Save your changes. ____________________________________________ Testing the Default field Value Edit your profile. Locate the new field Salutation field we just created. The default should be "Mr." or "M." depending on whether you are viewing the form in English or French. This indicates that the Default field value has an effect. Without this fix, "Dr." (the first value below "Choose...") would have been the default. ____________________________________________ Testing Saving Change the Salutation field to something other than Dr. and save your change. You should now see your Salutation field displayed in your profile. Unlike before, the value of the salutation field will now correctly display in the French version when you switch the Moodle user interface language to French.

      I am trying to add a Title/Salutation field to the User Profile form. I created a Menu of Choice type field called "salutation" and added the following multilingual content (I am using the multilingual filter):

      {mlang en}Mr.{mlang}{mlang fr}M{mlang}
      {mlang en}Mrs.{mlang}{mlang fr}Mme{mlang}
      {mlang en}Ms.{mlang}{mlang fr}Mlle{mlang}
      {mlang en}Dr.{mlang}{mlang fr}Dr{mlang}
      

      Everything works great except that the information saved to the database table only includes one language. As a result, when the information is later displayed, it appears only in the language in which the UI was set to at the time the information was saved. For example, if I select Mr. and then view the profile, it will correctly show Mr.. However if I then switch to the French view of the page, the salutation field will still show Mr. instead of M.

      The expected behaviour is that the information saved in the table be exactly what was entered in the "Menu Options (one per line)" field so that, anytime it is displayed, it will show up in the correct language whether the UI is set to English or French.

      I started tracing through the Moodle code. From what I can see, the full multilingual string should be stored in the custom field because only the value (a number) is ever submitted. Upon submission, the PHP code uses that number to look up the corresponding line. Unfortunately somewhere along the line (I haven't figured out where yet), a filter seems to be applied before the information is stored in the table.

            michael-milette Michael Milette
            michael-milette Michael Milette
            Sam Hemelryk Sam Hemelryk
            Adrian Greeve Adrian Greeve
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.