Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple attributes treated differently from single attribute in queryToArray #583

Open
OXINARF opened this issue Jun 3, 2019 · 0 comments

Comments

@OXINARF
Copy link

OXINARF commented Jun 3, 2019

//For backward compatibility
if (count($attributes) === 1) {
$array[$optionAttributeValue] = (string) $optionText;
} else {
$array[$optionText][$optionAttributeName] = (string) $optionAttributeValue;
}

This code forces the string type:

  • to the text when single attribute
  • to the attribute value on multiple attributes (and not to the text in this case)

It was detected when adding a new attribute to select options, which until then only had the typical value. When populating the default selected option, it would fail because the populated value was an int but the value was now a string.
I workaround it by casting the default selected value to a string when calling populateField, but it would be better to fix Former.

Proposed fix:

//For backward compatibility 
if (count($attributes) === 1) { 
    $array[$optionAttributeValue] = (string) $optionText; 
} else { 
    $array[(string) $optionText][$optionAttributeName] = $optionAttributeValue; 
} 

P.S.: I only come into contact with Former through another project so I might be completely missing something here, my apologies if so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants