Migrate Quickform Reference Documents
Compare changes
docs/framework/quickform/entityref.md
0 → 100644
+ 137
− 0
A special [api getlist](https://github.com/civicrm/civicrm-core/blob/master/api/v3/Generic/Getlist.php) action exists to support this widget. Getlist is a wrapper around the "get" action which smooths out the differences between various entities and supports features of the select2 widget such as infinite scrolling. It accepts the following settings (passed into the entityRef widget as 'api' property):
This step manipulates the parameters to the API magic get function. The core function ensures the api params include the return fields needed by Output. You should be sure to ensure the same return fields if you override this, or call the core function in your override. This step immediately precedes the API Entity Get.
Some entities are more complex and require additional pre/post processing of autocomplete results, for example to format the description differently or sort the results by date instead of alphabetically. For this, the following generic functions can be overridden: `_civicrm_api3_generic_getlist_defaults`, `_civicrm_api3_generic_getlist_params` and `_civicrm_api3_generic_getlist_output`. See [contact](https://github.com/civicrm/civicrm-core/blob/4.7.14/api/v3/Contact.php#L1248) and [event](https://github.com/civicrm/civicrm-core/blob/4.7.14/api/v3/Event.php#L237) apis for example implementations.
Unlike `_params` and `_output`, this is not an override of the core function. The return of your function will be fed in as the $apiDefaults (with precedence) to the [core defaults function](https://github.com/civicrm/civicrm-core/blob/4.7.14/api/v3/Generic/Getlist.php#L33). Despite the name, the defaults are only used by Getlist. If you do include a params array in the return, it will persist as defaults to API Entity get, but user supplied values will override them.
The input is not the API request but the params array of the API request. You most likely will implement this hook if you want to ensure settings get passed to a your own custom `_output` implementation, or change core behavior such as page size or set default label or id fields for your custom entity.