Add component update instructions to text_field_max_lengths migration doc
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -54,13 +54,61 @@ This is generated automatically from database schema metadata.
|
|||||||
|
|
||||||
## Migration Checklist
|
## Migration Checklist
|
||||||
|
|
||||||
### 1. Find all Text_Input components
|
### 1. Update Text_Input component files
|
||||||
|
|
||||||
|
**rsx/theme/components/inputs/text/text_input.js** - Add on_create() method:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
class Text_Input extends Form_Input_Abstract {
|
||||||
|
on_create() {
|
||||||
|
super.on_create();
|
||||||
|
|
||||||
|
// Only require $max_length when Text_Input is used directly, not subclasses
|
||||||
|
if (this.constructor === Text_Input && this.args.max_length === undefined) {
|
||||||
|
console.error(
|
||||||
|
`Text_Input with $name="${this.args.name}" requires $max_length. ` +
|
||||||
|
`Use $max_length=Model_Name.field_length('column_name') for database-driven limits, ` +
|
||||||
|
`a numeric value for custom limits, or -1 for unlimited.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... rest of existing code (keep _get_value, _set_value, on_ready, seed)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**rsx/theme/components/inputs/text/text_input.jqhtml** - Update template:
|
||||||
|
|
||||||
|
1. Change all `this.args.maxlength` to `this.args.max_length`
|
||||||
|
2. Change condition from `if (this.args.maxlength)` to `if (this.args.max_length > 0)`
|
||||||
|
3. Add maxlength to textarea (was missing before):
|
||||||
|
|
||||||
|
```html
|
||||||
|
<textarea $sid="input"
|
||||||
|
class="form-control"
|
||||||
|
rows="<%= this.args.rows || 3 %>"
|
||||||
|
placeholder="<%= this.args.placeholder || '' %>"
|
||||||
|
<% if (this.args.max_length > 0) { %>maxlength="<%= this.args.max_length %>"<% } %>
|
||||||
|
<% if (this.args.disabled) { %>disabled<% } %>></textarea>
|
||||||
|
```
|
||||||
|
|
||||||
|
Apply the same `max_length > 0` check to both input elements in the template.
|
||||||
|
|
||||||
|
### 2. Rebuild manifest
|
||||||
|
|
||||||
|
```bash
|
||||||
|
php artisan rsx:manifest:build --clean
|
||||||
|
```
|
||||||
|
|
||||||
|
This regenerates JS model stubs with the new `field_length()` method.
|
||||||
|
|
||||||
|
### 3. Find all Text_Input usage in forms
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
grep -rn '<Text_Input' rsx/app --include="*.jqhtml" --include="*.blade.php"
|
grep -rn '<Text_Input' rsx/app --include="*.jqhtml" --include="*.blade.php"
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Add $max_length to each
|
### 4. Add $max_length to each
|
||||||
|
|
||||||
For database-backed fields (recommended):
|
For database-backed fields (recommended):
|
||||||
```html
|
```html
|
||||||
@@ -77,7 +125,7 @@ For truly unlimited fields (use sparingly):
|
|||||||
<Text_Input $name="notes" $type="textarea" $max_length=-1 />
|
<Text_Input $name="notes" $type="textarea" $max_length=-1 />
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Verify no console errors
|
### 5. Verify no console errors
|
||||||
|
|
||||||
Load each form and check browser console. Any Text_Input missing `$max_length` will log:
|
Load each form and check browser console. Any Text_Input missing `$max_length` will log:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user