8000 Textarea TV loses Auto Grow and Resizable settings on reload · Issue #16746 · modxcms/revolution · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Textarea TV loses Auto Grow and Resizable settings on reload #16746

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

Open
eremozin opened this issue May 16, 2025 · 2 comments
Open

Textarea TV loses Auto Grow and Resizable settings on reload #16746

eremozin opened this issue May 16, 2025 · 2 comments
Labels
bug The issue in the code or project, which should be addressed.

Comments

@eremozin
Copy link

Bug Report

Summary

The Textarea TV with Auto Grow and Resizable enabled resets these settings when the TV is reloaded or reopened.

Steps to Reproduce

  1. Create a Template Variable (TV) with the input type set to Textarea.
  2. Disable Auto Grow and Resizable options.
  3. Save and reload or reopen the TV.

Environment

MODX version: 3.1.2-pl

@eremozin eremozin added the bug The issue in the code or project, which should be addressed. label May 16, 2025
@halftrainedharry
Copy link
Contributor

The problem seems to be the function paramValueIsTrue() that was added with #16553 (in MODX 3.1.0):

* Evaluate boolean-like parameter value and return it as an actual boolean or as a string; a string may be
* needed/preferred when building code blocks (e.g., javascript) via php strings (nowdoc/heredoc ones in particular).
*
* @param array $params An associative or numeric-indexed array of parameters
* @param string|int $key The array key to evaluate
* @param bool $returnBoolAsString Whether to return the string representation ('true' or 'false') of the boolean value
* @return string|bool
*/
public function paramValueIsTrue(array $params, $key, bool $returnBoolAsString = false)
{
if (isset($params[$key]) && in_array($params[$key], ['true', true, '1', 1])) {
return $returnBoolAsString ? 'true' : true ;
}
return $returnBoolAsString ? 'false' : false ;
}

Because in_array('false',[true]); seems to return true in PHP, the function returns true when the value is the string 'false'.

@halftrainedharry
Copy link
Contributor

The solution is probably to use the third parameter ($strict) of the in_array function and to change the line

if (isset($params[$key]) && in_array($params[$key], ['true', true, '1', 1])) {

to this instead:

if (isset($params[$key]) && in_array($params[$key], ['true', true, '1', 1], true)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue in the code or project, which should be addressed.
Projects
None yet
Development

No branches or pull requests

2 participants
0