Back

provides()

Name Type Required Default Description
formats string No Formats to instruct the controller to provide. Valid values are html (the default), xml, json, csv, pdf, and xls.
1. Provide HTML, XML, and JSON responses
function config() {
    provides("html,xml,json");
}

2. Provide only JSON and CSV
function config() {
    provides("json,csv");
}

3. Default behavior (HTML only)
function config() {
    provides(); // equivalent to provides("html")
}

4. Handling requested format in the action
function show() {
    // Wheels automatically detects the requested format and renders accordingly
    renderwith(data=model("user").findByKey(params.id));
}
Copied!