Skip to content

Form saving not working for hyphenated locales #8787

@oxcar

Description

@oxcar

Describe the bug

Organizations with hyphenated locales (e.g. "es-MX") are not working properly when saving forms.

To Reproduce

Some steps to reproduce the behavior:

  1. A clean instalation of Decidim, with only one organization with one hyphenated locale as the only locale (es-MX).
  2. Login as Admin user
  3. Go to AdConfiguración / Editar organización
  4. Click Actualizar at the bottom of the page

Expected behavior
It should save the form correctly.

Screenshots
Screenshot 2022-02-05 at 01-08-47 Action Controller Exception caught

Extra data (please complete the following information):

  • Device: Desktop
  • Device OS: MacOs
  • Browser: Firefox
  • Decidim Version: 0.25.2

Additional context

I think the problem is related to file https://github.com/decidim/decidim/blob/develop/decidim-core/app/forms/translatable_presence_validator.rb

line 12: translated_attr = "#{attribute}_#{default_locale_for(record)}"

Attribute "admin_terms_of_use_body" with hyphenated locale "es-MX" becomes "admin_terms_of_use_body_es-MX", but it should be "admin_terms_of_use_body_es__MX".

Also, for reference, in a form like in file https://github.com/decidim/decidim/blob/develop/decidim-admin/app/forms/decidim/admin/organization_form.rb

In line 36: translatable_attribute :admin_terms_of_use_body, String gets injected as admin_terms_of_use_body_es__MX when locale is "es-MX".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions