ForageWeb.ForageController (forage v0.5.0)

Helper functions for Plug controllers that use forage.

Link to this section Summary

Functions

Renders paginated data into a shape that the select widget expects.

Renders paginated data into a shape that the select widget expects. Takes in either a field name (text_field) or a converter function to convert the entries into text.

Renders paginated data into a shape that the select widget expects. Removes pagination data.

Extracts the pagination data from the request params

Link to this section Functions

Link to this function

forage_select_data(paginated)

Renders paginated data into a shape that the select widget expects.

This function returns a map. The user must use the JSON encoder in the Phoenix application to generate a JSON response.

It would be more succint to return JSON directly from this function, but Forage has no way of invoking the application's JSON encoder, so we leave that responsibility to the user.

Examples:

TODO

Link to this function

forage_select_data(paginated, converter)

Renders paginated data into a shape that the select widget expects. Takes in either a field name (text_field) or a converter function to convert the entries into text.

This function returns a map. The user must use the JSON encoder in the Phoenix application to generate a JSON response.

It would be more succint to return JSON directly from this function, but Forage has no way of invoking the application's JSON encoder, so we leave that responsibility to the user.

Examples:

TODO

Link to this function

forage_select_data_without_pagination(entries)

Renders paginated data into a shape that the select widget expects. Removes pagination data.

This function returns a map. The user must use the JSON encoder in the Phoenix application to generate a JSON response.

It would be more succint to return JSON directly from this function, but Forage has no way of invoking the application's JSON encoder, so we leave that responsibility to the user.

Examples:

TODO

Link to this function

forage_select_maps(maps)

Link to this function

pagination_from_params(params)

Extracts the pagination data from the request params