Skip to content

Refine 1.0 form manual for Ray.WebFormModule 1.0.0#358

Merged
koriym merged 5 commits into
bearsunday:masterfrom
koriym:webform-1.0-update
May 18, 2026
Merged

Refine 1.0 form manual for Ray.WebFormModule 1.0.0#358
koriym merged 5 commits into
bearsunday:masterfrom
koriym:webform-1.0-update

Conversation

@koriym

@koriym koriym commented May 18, 2026

Copy link
Copy Markdown
Member

Summary

Refresh both the Japanese and English form manuals to match the Ray.WebFormModule 1.0.0 source of truth (CHANGELOG + README):

  • Revert mistaken rename: the real module class is still AuraInputModule (no rename happened in 1.0.0). The previous commit on this branch had renamed it to a non-existent WebFormModule.
  • Correct attribute parameter: #[FormValidation] exposes form and onFailure (not onValidationFailed). Keep the default ValidationFailed-suffix behaviour.
  • Modern DI style: use #[Inject] setForm(#[Named] FormInterface) with typed properties (matching README and tests).
  • Tighten signatures with explicit parameter and return types to match the typed PHP 8 APIs.
  • ToStringInterface note: echo \$form renders the whole form when the form implements ToStringInterface.
  • CSRF is opt-in: replace the standalone CSRF section with the #[CsrfProtection] explanation (the removed antiCsrf=true option is no longer available).
  • Migration from 0.x table: summarise the BC breaks (annotations to attributes, antiCsrf=true split into #[CsrfProtection], Reader argument removal, FormInterface signature updates) and link to the migrate-to-1.0 Claude Code skill in the upstream repo.

Test plan

  • Visual check of the rendered manual at manuals/1.0/ja/form.html and manuals/1.0/en/form.html
  • Confirm code samples copy-paste cleanly into a BEAR.Sunday app on Ray.WebFormModule 1.0.0

Summary by CodeRabbit

  • Documentation
    • Webフォーム処理に関するドキュメントを大幅に更新
    • 統一されたフォームクラスの使用方法と実装例を記載
    • WebFormModuleのインストール手順と設定方法を明確化
    • バリデーション、CSRF保護、エラーハンドリングの新しいパターンと実装例を説明
    • 旧バージョンからの移行ガイドとデモアプリへの参照を追加

Review Change Stack

Reflect the BC break in Ray.WebFormModule 1.0.0 where CSRF protection
is now opt-in via a separate #[CsrfProtection] attribute, instead of
the removed antiCsrf=true option on #[FormValidation]. Also fix the
legacy AuraInputModule references in the English manual to match the
current WebFormModule name.
@koriym

koriym commented May 18, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Refresh both the Japanese and English form manuals to align with the
1.0.0 source of truth and README:

- Revert the previous WebFormModule rename: the real class is still
  AuraInputModule (no rename happened in 1.0.0).
- Document the actual #[FormValidation] parameters (form, onFailure)
  instead of the obsolete onValidationFailed name, and keep the
  default ValidationFailed suffix behaviour.
- Use the modern method-injection style for the form
  (#[Inject] setForm(#[Named] FormInterface) with typed properties),
  matching the README and tests.
- Tighten init()/onPost() signatures with explicit return types and
  parameter types to match PHP 8 typed APIs.
- Note that the entire form can be rendered with echo when the form
  implements ToStringInterface.
- Replace the standalone CSRF section with the opt-in #[CsrfProtection]
  explanation from the README.
- Add a 'Migration from 0.x' table summarising the BC breaks (Doctrine
  annotations to attributes, antiCsrf=true to #[CsrfProtection],
  Reader argument removal, FormInterface signature updates) and link
  to the migrate-to-1.0 Claude Code skill.
@koriym koriym changed the title Document Ray.WebFormModule 1.0.0 #[CsrfProtection] attribute Refine 1.0 form manual for Ray.WebFormModule 1.0.0 May 18, 2026
@koriym

koriym commented May 18, 2026

Copy link
Copy Markdown
Member Author

Refined the entire form manual against the 1.0.0 source (README is the truth):

  • Reverted the previous AuraInputModuleWebFormModule rename — AuraInputModule is still the real class name.
  • Fixed #[FormValidation] parameter to the actual onFailure (was onValidationFailed).
  • Switched the controller example to the modern #[Inject] setForm(#[Named] FormInterface) style with typed properties.
  • Replaced the CSRF section with the opt-in #[CsrfProtection] story.
  • Added a 0.x → 1.0 migration table linking to the migrate-to-1.0 Claude Code skill.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

@koriym, I'll kick off a fresh review of your refined form manual. The changes you've described — reverting AuraInputModule, correcting onFailure, modernising the #[Inject] / #[Named] DI style, the opt-in #[CsrfProtection] story, and the 0.x → 1.0 migration table — all sound well-aligned with the 1.0.0 README as the source of truth. Starting the review now!

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

英語版・日本語版のフォーム関連ドキュメントをWebFormModuleとPHP 8 Attributesベースの実装に統一し、#[FormValidation]・#[CsrfProtection]・#[InputValidation]・#[VndError]属性の使用例を追加し、CSRFがopt-in仕様であることを明示し、FormVndErrorModuleとの組み合わせ、0.x からの移行ガイドを整理しました。

Changes

Form module documentation updates

Layer / File(s) Summary
WebFormModule installation in AppModule
manuals/1.0/en/form.md, manuals/1.0/ja/form.md
composerを用いたWebFormModuleの導入と、AppModuleでのWebFormModuleインスタンス生成・install()呼び出しの手順を英語版・日本語版で統一しました。
Form class definition and validation attributes
manuals/1.0/en/form.md, manuals/1.0/ja/form.md
AbstractFormを継承したフォームクラス、init()での入力要素登録、#[FormValidation]による検証成功/失敗時のメソッド呼び出し、#[CsrfProtection]によるCSRF opt-in、#[InputValidation]とValidationException、input()/error()によるビュー要素取得の流れをコード例付きで説明しました。
Error payload extension and FormVndErrorModule
manuals/1.0/en/form.md, manuals/1.0/ja/form.md
vnd.error+json形式での例外ペイロード、#[VndError]によるメタデータ追加、FormVndErrorModuleの導入、Doctrine AnnotationsからPHP 8 Attributesへの移行、CSRF opt-in化、デモアプリリンクを追加しました。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、変更内容の主な目的である「Ray.WebFormModule 1.0.0に対応した1.0フォームマニュアルの改善」を明確かつ簡潔に表現しており、チームメンバーが履歴を見てすぐに主要な変更内容を理解できます。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

koriym added 3 commits May 18, 2026 17:02
The detailed migration table belongs in the library's README and
CHANGELOG, not in the framework manual. Replace the table with a
short note that links to both, keeping the manual focused on how to
use Ray.WebFormModule 1.0.0.
Self-review found that the controller examples returned ResourceObject
without extending it (and without importing it), so they would not run
as-is. Rewrite the controller examples as Page resources, which is the
native style for a BEAR.Sunday manual:

- class MyPage extends ResourceObject with the matching import
- constructor promotion to inject the named form
- method signatures return static and end with return $this
- drop init(): void so the form class matches the parent
  Aura\Input\Fieldset::init() signature used in the library and tests
Ray.WebFormModule 1.0.1 ships Ray\WebFormModule\WebFormModule whose
name lines up with the package and namespace. Update the form manual
samples to install the new class. The legacy AuraInputModule remains
as a thin subclass for backwards compatibility, so no behaviour
changes for existing apps.
@koriym

koriym commented May 18, 2026

Copy link
Copy Markdown
Member Author

@koriym Updated to use the new Ray\WebFormModule\WebFormModule class introduced in ray-di/Ray.WebFormModule#29. The legacy AuraInputModule remains as a thin subclass for backwards compatibility.

Please merge this PR only after Ray.WebFormModule 1.0.1 has been released, so the WebFormModule class referenced in the samples actually exists on Packagist.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
manuals/1.0/ja/form.md (1)

73-86: ⚡ Quick win

日本語版も #[Inject] + setForm() 形式に統一してください。

Line 73-86 はコンストラクタ注入のままで、PR目的の「#[Inject] setForm(#[Named] FormInterface) へ統一」とズレています。英語版と同時に揃えると、日英で同一の移行手順として使えます。

差分例
 use BEAR\Resource\ResourceObject;
+use Ray\Di\Di\Inject;
 use Ray\Di\Di\Named;
 use Ray\WebFormModule\Annotation\FormValidation;
 use Ray\WebFormModule\FormInterface;

 class MyPage extends ResourceObject
 {
-    public function __construct(
-        #[Named('contact_form')] private FormInterface $contactForm,
-    ) {
-    }
+    private FormInterface $contactForm;
+
+    #[Inject]
+    public function setForm(#[Named('contact_form')] FormInterface $contactForm): void
+    {
+        $this->contactForm = $contactForm;
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@manuals/1.0/ja/form.md` around lines 73 - 86,
この日本語ドキュメントのサンプルをコンストラクタ注入から英語版と揃えた setter 注入へ変更してください:MyPage クラスのコンストラクタでの
FormInterface $contactForm 注入を削除し、代わりに #[Inject] を付けた public または protected
setForm(#[Named('contact_form')] FormInterface $form)
メソッドを追加して内部プロパティを設定するようにし、FormValidation の参照(#[FormValidation(form:
'contactForm')]) が新しいフォーム識別子と一致することを確認してください(メソッド名/プロパティ名は setForm と
contact_form を参照)。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@manuals/1.0/ja/form.md`:
- Around line 73-86: この日本語ドキュメントのサンプルをコンストラクタ注入から英語版と揃えた setter
注入へ変更してください:MyPage クラスのコンストラクタでの FormInterface $contactForm 注入を削除し、代わりに
#[Inject] を付けた public または protected setForm(#[Named('contact_form')]
FormInterface $form) メソッドを追加して内部プロパティを設定するようにし、FormValidation
の参照(#[FormValidation(form: 'contactForm')])
が新しいフォーム識別子と一致することを確認してください(メソッド名/プロパティ名は setForm と contact_form を参照)。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0f1b3ec0-289f-4e95-9d5b-aecd5f2cfa3d

📥 Commits

Reviewing files that changed from the base of the PR and between 05ca6f6 and ba3ccd3.

📒 Files selected for processing (2)
  • manuals/1.0/en/form.md
  • manuals/1.0/ja/form.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant