fix textarea default value in multipage forms#2108
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (1)classes/models/fields/FrmFieldTextarea.php (1)
The change correctly implements a fallback mechanism to use the default value when the field value is empty. This fix:
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
| return '<textarea name="' . esc_attr( $args['field_name'] ) . '" id="' . esc_attr( $args['html_id'] ) . '" ' . | ||
| $rows . $input_html . '>' . | ||
| FrmAppHelper::esc_textarea( $this->field['value'] ) . | ||
| FrmAppHelper::esc_textarea( ! empty( $this->field['value'] ) ? $this->field['value'] : $this->field['default_value'] ) . |
There was a problem hiding this comment.
Thanks @engahmeds3ed.
Unfortunately these sorts of issues are a bit more complex.
This code is also used if I'm editing an entry for example with no value. It will show the default even though I had previously put nothing. There's other code that sets $this->field['value'] to the default, and other code that clears these values when conditionally hidden. We have some JS that restores default values when a field is shown again. When the field isn't visible, we want it to have no value. We generally fix these sorts of issues a bit differently.
We have a few similar issues that we need to figure out still.
- https://github.com/Strategy11/formidable-pro/issues/4081
- https://github.com/Strategy11/formidable-pro/issues/4110
The ! empty also wouldn't be totally safe since it would break 0 values.
I plan to try looking further into this.
|
Closing this for now as I don't think we'll be going in this direction. I think the fix will likely be in Pro code since this issue isn't related to Lite either. |
Fixes https://github.com/Strategy11/formidable-pro/issues/5470
We validated the fix in the customer's site and it's working properly.