Skip to content

Commit

Permalink
Update custom_fields.md
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 authored Aug 16, 2021
1 parent d769cba commit 1796e64
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/custom_fields.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
## Custom Fields
You can generate a custom field with:

```bash
rails g madmin:field Custom
```

This will create a CustomField class in app/madmin/fields/custom_field.rb And the related views:

```bash
# -> app/views/madmin/fields/custom_field/_form.html.erb
# -> app/views/madmin/fields/custom_field/_index.html.erb
# -> app/views/madmin/fields/custom_field/_show.html.erb
```

You can then use this field on our resource:

```ruby
class PostResource < Madmin::Resource
attribute :title, field: CustomField
end
end
```

0 comments on commit 1796e64

Please sign in to comment.