Fixed
Details
Priority
MinorAssignee
AlexAlexReporter
Gleb SinkovskiyGleb SinkovskiyDeveloper
Gleb SinkovskiyGleb SinkovskiyReviewer
AlexAlexChange Log Group
AddedChange Log Message
Added ability to use field title in the validation error messages (e.g. "First Name is required" instead of "Field is required").Patch Instructions
Patches must be submitted through Phabricator.
To submit patch via Command Line use Patches Workflow (via Arcanist) tutorial.
To submit patch via Web Interface use Patches Workflow (via Web Interface) tutorial.
BC Break Details
the "%s", "%1$s" and similar are no longer processed inside error message phrases and cause notice
Solution
In the "kValidator::GetErrorMsg" method, when "$params" (error message params) array:
when error message contains "%" that is followed by non-whitespace symbol we execute old code (get from SVN), where "sprintf" was used
otherwise execute current code with " {param_name}" replacement
At the end both approach should work, since we're not planning to deprecate "%s" approach in error messages.
Story Points
1Fix versions
Details
Details
Priority
Assignee
Alex
AlexReporter
Gleb Sinkovskiy
Gleb SinkovskiyDeveloper
Gleb Sinkovskiy
Gleb SinkovskiyReviewer
Alex
AlexChange Log Group
Added
Change Log Message
Added ability to use field title in the validation error messages (e.g. "First Name is required" instead of "Field is required").
Patch Instructions
Patches must be submitted through Phabricator.
To submit patch via Command Line use Patches Workflow (via Arcanist) tutorial.
To submit patch via Web Interface use Patches Workflow (via Web Interface) tutorial.
BC Break Details
the "%s", "%1$s" and similar are no longer processed inside error message phrases and cause notice
Solution
In the "kValidator::GetErrorMsg" method, when "$params" (error message params) array:
when error message contains "%" that is followed by non-whitespace symbol we execute old code (get from SVN), where "sprintf" was used
otherwise execute current code with " {param_name}" replacement
At the end both approach should work, since we're not planning to deprecate "%s" approach in error messages.
Story Points
1
Fix versions
Created September 18, 2014 at 10:40 AM
Updated December 29, 2024 at 8:57 PM
Resolved August 17, 2016 at 8:25 AM
1. locate "SetError" methods calls in the "kValidator" class, where additional parameters are passed to the error (I found 3)
2. in each found case transform index-based parameter array into associative array by assigning name for each of given parameters
3. in the "GetErrorMsg" method:
add "array_values" before giving error params to "vsprintf" function
after call to "ReplaceLanguageTags" we need to add "field" parameter to the error parameters, which value would be translation of this phrase: "la_fld_FieldName" (in Admin Console) and "lu_fld_FieldName" (on Front-End)
replace all named parameter occurrences in a string (before "la-la {param_name} la-la", after "la-la value_of_param_name_parameter la-la")
after named parameter is replaced (check number of actual replacements made) remove it from parameter list