Commit f335cb5
authored
Conventional location and name for custom field (#2842)
There is an inconsistency between the `administrate:field` generator and the
custom field `HasManyVariant` present in the demo app. They use different
conventions for naming and file paths.
After thinking about which of the two styles is right or wrong, I think the
generator is doing the right thing. This PR moves `HasManyVariant` and
renames it `HasManyVariantField`, in order to follow the convention set out
by the generator (which is also the one shown in the docs).
Notes:
- The field class is generated under `app/fields`. The location means it's
autoloaded and we don't need a `require`.
- The `Field` suffix may seem annoying, but it's not different from
controllers, helpers, etc, and removes the need for a namespace
(eg: `Field::HasManyVariant`).
- This establishes a difference between the official field types
(eg: `Administrate::Field::String`) and custom ones (eg:
`MyStringField`), but I think this is fine.
Tangentially I also noticed that, if for any reason a user puts the template
files in the wrong place, this is difficult to debug as Administrate will
just fail silently, rendering empty templates. This is due to the changes
introduced at #2467. This
should not be an issue if using the generator, but might be if creating the
field manually.1 parent 14e042a commit f335cb5
File tree
4 files changed
+5
-13
lines changed- spec
- example_app
- app
- dashboards
- fields
- lib/administrate/field
- helpers/administrate
4 files changed
+5
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
12 | | - | |
| 11 | + | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 0 additions & 9 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | | - | |
| 15 | + | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
0 commit comments