Skip to content
Snippets Groups Projects
Commit 74efb328 authored by Sean Madsen's avatar Sean Madsen
Browse files

Improve markdown formatting

parent 57c58f8e
No related branches found
No related tags found
1 merge request!279Migrate Quickform Reference Documents
# EntityRef Fields
## Introduction
This widget was added in CiviCRM v4.5 and supplants the old autocomplete + hidden field techniques. A flexible form widget for finding/selecting/creating contacts and other entities.
## Features
......@@ -19,7 +20,7 @@ An entityRef widget can be created via quickform on the server-side, or
using jQuery on the client-side.
**PHP: From a buildForm function**
### PHP: From a buildForm function
```php
// With no parameters passed in, will create a single contact select
......@@ -54,9 +55,9 @@ $this->addEntityRef('field_5', ts('Activity Type'), array(
Please see code-level documentation in [CRM_Core_Form](https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/Form.php#L1813) for all available params.
**JS: Add from client-side**
### JS: Add from client-side
```javascript
```html
<input name="my_field" placeholder="{ts}- select organization -{/ts}" />
<script type="text/javascript">
......@@ -71,7 +72,8 @@ Please see code-level documentation in [CRM_Core_Form](https://github.com/civicr
</script>
```
Note: Instead of passing params into the jQuery.crmEntityRef function, an alternative is to attach them as html data attributes. This is how they are passed from php forms onto the clientside.
!!! note
Instead of passing params into the `jQuery.crmEntityRef` function, an alternative is to attach them as html data attributes. This is how they are passed from php forms onto the client-side.
## Getlist API
......
......@@ -109,7 +109,7 @@ These basic elements can be added using `CRM_Core_Form()->add()`
| addMoney | money field + select currency | |
| addEntityRef | autocomplete select of contacts, tags, events, etc. | [EntityRef documentation](/framework/quickform/entityref) |
#### Deprecated Form Elements
### Deprecated Form Elements
| Method | Was Used For | Notes |
| --- | --- | --- |
......@@ -125,7 +125,7 @@ These basic elements can be added using `CRM_Core_Form()->add()`
CiviCRM provides a more nuanced request lifecycle than traditional `HTML_QuickForm`. This extended request lifecycle allows the original web developer to create the form using a class – and allows third-party developers to modify the form using hooks. The request lifecycle is divided into a few phases, and each phase may have multiple steps. The phases and steps are presented in sequence:
**Build Phase**
### Build Phase
Generate a set of HTML form fields (`$form->addElement()`, `$form->add()`, etc) and validation rules (`$form->addFormRule()`) to the form. (Note: The "Build" phase runs during the initial GET request and the subsequent POST request.)
......@@ -133,28 +133,31 @@ Generate a set of HTML form fields (`$form->addElement()`, `$form->add()`, etc)
| --- | --- | --- |
| `CRM_Core_Form::preProcess` (override) | Original Developer | In any subclass of `CRM_Core_Form`, the `preProcess()` function can be overridden. |
| `CRM_Core_Form::buildQuickForm` (override) | Original Developer | In any subclass of `CRM_Core_Form`, the `buildQuickForm()` function can be overridden. |
| [hook_civicrm_buildForm](/hooks/hook_civicrm_buildForm) | Third-Party Developer | |
| [hook_civicrm_buildForm](/hooks/hook_civicrm_buildForm.md) | Third-Party Developer | |
| `CRM_Core_Form::addRules` (override) | Original Developer | In any subclass of `CRM_Core_Form`, the `addRules()` function can be overridden.
**Validate Phase**
### Validate Phase
Examine submitted form data to determine validity. (Note: The "Validation" phase runs during the POST request.)
| Step | Audience | Comments |
| --- | --- | --- |
| (Process rules) | Original Developer & Third-Party Developer | Iteratively process any rules that here added during the "build" phase (i.e. call any callbacks registered via `$form()->addFormRule()`). |
| [hook_civicrm_validate()](/hooks/hook_civicrm_validate) | Third-Party Developer | (Note: This is similar to `hook_civicrm_validateForm` but older) |
| [hook_civicrm_validateForm()](/hooks/hook_civicrm_validateForm) | Third-Party Developer | (Note: This is similar to `hook_civicrm_validate`; added in CiviCRM v4.2) |
| [hook_civicrm_validate()](/hooks/hook_civicrm_validate.md) | Third-Party Developer | (Note: This is similar to `hook_civicrm_validateForm` but older) |
| [hook_civicrm_validateForm()](/hooks/hook_civicrm_validateForm.md) | Third-Party Developer | (Note: This is similar to `hook_civicrm_validate`; added in CiviCRM v4.2) |
**Process Phase**
### Process Phase
Save the data, execute business logic, etc. (Note: The "Process" phase runs during the POST request – but only if the "Validation" was successful)
| Step | Audience | Comments |
| --- | --- | --- |
| `CRM_Core_Form::postProcess` (override) | Original Developer | In any subclass of `CRM_Core_Form`, the `postProcess()` function can be overridden. |
| [hook_civicrm_postProcess](/hooks/hook_civicrm_postprocess) | Third-Party Developer | |
| [hook_civicrm_postProcess](/hooks/hook_civicrm_postprocess.md) | Third-Party Developer | |
**Render Phase**
### Render Phase
Generate HTML using Smarty. (Note: The "Render" phase does not provide events or hooks to the PHP controller.)
Generate HTML using Smarty.
!!! note
The "Render" phase does not provide events or hooks to the PHP controller.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment