FormTypeのコーディング見直し
- Dominant language
- PHP
- Stars
- 788
- Forks
- 719
- Avg merge
- 3d 20h
- Merged PRs (30d)
- 45
Description
## 概要(Overview)
FormTypeの実装にばらつきがあるため、以下のように実装を見直します。
### ディレクトリ構造
- Admin:管理画面で使用するもの
- CustomerType
- OrderType
- ...
- Front:フロント画面で使用するもの
- Install:Webインストーラで使用するもの
- Master:Master系
PriceTypeやNameTypeなど、項目レベルで共通して利用するものはルートに配置します
### BlockPrefixについて
- 現状、命名にばらつきがある
- 重複すると、form_themeのレンダリングに支障が出る場合がある
- `Eccube\Form\Type\Admin\CustomerType` -> `eccube_admin_customer`を命名規約とする
- AbstractType::getBlockPrefixをオーバライドしたクラスを用意
### ラベル/ツールチップ
- ラベルは必ず定義する(多言語化のメッセージIDを指定)
- ツールチップは管理画面FormTypeの場合に指定する(多言語化のメッセージIDを指定)
### 文字長のバリデーション
- 文字列(Text, TextArea)の場合
- varcharは、255 or 4000(エンティティのカラム定義に合わせる)
- textは99999(lltextlen相当)
- 業務的に意味のあるモノ(郵便番号等)はその仕様に合わせる
- 数値(Integer, Number)の場合
- GreatorThan/LessThan等でチェックする
- smattint上限/int上限を指定
- 桁数チェックは行わない(カンマなどが入る場合があり判定が難しい)
### html属性
- requiredで自動NotBlankの廃止( #1577 )
- requiredはデフォルトtrueなので、'required' => trueは削除
- max_lengthは文字列の項目(TextType, TextAreaType)の場合必ず指定する
### その他
- クラス名FQDNは`XXX::class`を使う
Contributor guide
Research direction
The issue names Eccube\Form\Type\Admin\CustomerType and AbstractType::getBlockPrefix as entry points; begin by inventorying the existing Admin, Front, Install, and Master FormType directories and their current block prefixes. Compare each form against the stated label, tooltip, validation, HTML-attribute, and FQDN rules; done means the layout and conventions are applied consistently without duplicate prefixes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, symfony
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100