PTools 5.57.0 Form 2.0 Migration / 迁移 / Migración
English
Form 2.0 keeps the existing public constructors and field kinds. Existing uses of PTFormEngine(fields:), PTFormViewController(form:), and PTFormField(…) do not require source changes.
The important behavior change is that PTFormEngine(fields:sections:) now presents each declared section as a real PTSection. Earlier code used sections only to order fields and the controller flattened everything into one “form” section. If the old flat appearance is required, use PTFormConfiguration(sectionPresentation: .flat) or provide one explicit section.
New code should prefer PTFormConfiguration for form-level safe-area, spacing, validation, keyboard and interaction policy; PTFormSectionConfiguration for section insets, row spacing, header/footer and appearance; PTFormSnapshot and PTFormCollectionAdapter for typed multi-section presentation; PTFormFieldConfiguration and PTFormFieldRenderContext for adaptive field layout and custom renderers; and PTFormValidationContext with PTFormCrossValidator for cross-field validation.
Definition problems are reported through await form.definitionIssues; they no longer trigger a debug-only assertion that can terminate the host application. Fix duplicate IDs and missing field references before release.
中文
Form 2.0 保留现有公开构造器和字段类型。PTFormEngine(fields:)、PTFormViewController(form:) 和 PTFormField(…) 现有调用无需修改。
重要行为变化是:PTFormEngine(fields:sections:) 现在会把每个 Section 渲染为真实的 PTSection。旧版本只用 Section 排序字段,控制器最后会把所有字段压成一个 “form” Section。如果仍需要旧的扁平外观,使用 PTFormConfiguration(sectionPresentation: .flat),或显式只提供一个 Section。
非法定义通过 await form.definitionIssues 返回,不再使用可能终止宿主应用的 Debug 断言。发布前应修复重复 ID 和缺失字段引用。
Español
Form 2.0 conserva los constructores públicos y los tipos de campo existentes. Las llamadas actuales a PTFormEngine(fields:), PTFormViewController(form:) y PTFormField(…) no necesitan cambios.
El cambio importante es que PTFormEngine(fields:sections:) ahora muestra cada sección como un PTSection real. Antes las secciones solo ordenaban campos y el controlador aplanaba todo en una sección “form”. Para conservar la apariencia plana usa PTFormConfiguration(sectionPresentation: .flat) o declara una sola sección.
Los problemas de definición se exponen mediante await form.definitionIssues y ya no terminan la aplicación anfitriona con una aserción de depuración. Corrige los IDs duplicados y las referencias ausentes antes de publicar.