Skip to content

Creating components

Gabriel Cardoso edited this page Sep 15, 2016 · 12 revisions

Para comes without general purpose components to create simple forms and CRUDs, and allows to create your own components.

Basic components

These are the basic components :

  • The :crud component, which allows to display a simple table / form CRUD structure for a given model. Useful for most of the user-facing models of your app.
  • The :form components, which creates a simple form for a single instance of a given model. Useful for configuration interfaces and other models which may be easily edited as a single form instead of having a single instance in a table and using a :crud component.

Most of the time, a combination of those two components, with the other customization capacities of Para will be enough to cover your needs.

If you need to create a special component, from scratch or inheriting from existing components functionality, you can build your own components, as described below.

Customizing basic components

Extending the :crud component

If you only need to add functionnality to a specific :crud component, you can override the controller used by your component to access your data.

Most of the time, you'll want that controller to keep existing code and add some features to it.

This can be acomplished by creating a controller inheriting from the Para::Admin::CrudResourcesController, adding missing routes and forcing it to be used by your component in your config/components.rb file.

You can find examples here : Overriding and adding actions to components

Extending the :form component

This works exactly the same as extending the :crud component as described above.
The only difference is that you'll use a different parent class for your controller (Para::Admin::FormResourcesController) and a different helper in your routes (form_component).

Clone this wiki locally