Add Polymorphic_Field_Helper for JSON-encoded polymorphic form fields

Fix incorrect data-sid selector in route-debug help example
Fix Form_Utils to use component.$sid() instead of data-sid selector
Add response helper functions and use _message as reserved metadata key

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-12-23 23:26:55 +00:00
parent f5b901762c
commit eb3ccd722d
3 changed files with 467 additions and 0 deletions

View File

@@ -924,6 +924,30 @@ public static function save(Request $request, array $params = []) {
Details: `php artisan rsx:man form_conventions`
### Polymorphic Form Fields
For fields that can reference multiple model types (e.g., an Activity linked to either a Contact or Project), use JSON-encoded polymorphic values.
```php
use App\RSpade\Core\Polymorphic_Field_Helper;
$eventable = Polymorphic_Field_Helper::parse($params['eventable'], [
Contact_Model::class,
Project_Model::class,
]);
if ($error = $eventable->validate('Please select an entity')) {
$errors['eventable'] = $error;
}
$model->eventable_type = $eventable->model;
$model->eventable_id = $eventable->id;
```
Client submits: `{"model":"Contact_Model","id":123}`. Always use `Model::class` for the whitelist.
Details: `php artisan rsx:man polymorphic`
---
## MODALS