-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Afform - Support embedding forms via WP shortcodes.
This gives very basic and flawed support for Afform shortcodes. It works, but - The afform must have a server_route defined for no other reason than because civi shortcodes expect a page callback - The widget for selecting an afform is terrible & search only works if you type the exact title
- Loading branch information
Showing
2 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* Get a list of afforms. | ||
* | ||
* @param array $params | ||
* | ||
* @return array | ||
* API result | ||
*/ | ||
function civicrm_api3_afform_get($params) { | ||
/** @var \CRM_Afform_AfformScanner $scanner */ | ||
$scanner = \Civi::service('afform_scanner'); | ||
|
||
$names = array_keys($scanner->findFilePaths()); | ||
$result = []; | ||
|
||
foreach ($names as $name) { | ||
$info = [ | ||
'name' => $name, | ||
'module_name' => _afform_angular_module_name($name, 'camel'), | ||
'directive_name' => _afform_angular_module_name($name, 'dash'), | ||
]; | ||
$record = $scanner->getMeta($name); | ||
$result[$name] = array_merge($record, $info); | ||
} | ||
|
||
$filterableFields = ['name', 'module_name', 'directive_name', 'server_route', 'type', 'description', 'title']; | ||
return _civicrm_api3_basic_array_get('Afform', $params, $result, 'name', $filterableFields); | ||
} | ||
|
||
function _civicrm_api3_afform_get_spec(&$fields) { | ||
$fields['name'] = [ | ||
'title' => 'Name', | ||
'api.aliases' => ['id'], | ||
'type' => CRM_Utils_Type::T_STRING, | ||
]; | ||
$fields['title'] = [ | ||
'title' => 'Title', | ||
'type' => CRM_Utils_Type::T_STRING, | ||
]; | ||
$fields['module_name'] = [ | ||
'title' => 'Module Name', | ||
'type' => CRM_Utils_Type::T_STRING, | ||
]; | ||
$fields['directive_name'] = [ | ||
'title' => 'Directive Name', | ||
'type' => CRM_Utils_Type::T_STRING, | ||
]; | ||
$fields['description'] = [ | ||
'title' => 'Description', | ||
'type' => CRM_Utils_Type::T_STRING, | ||
]; | ||
$fields['server_route'] = [ | ||
'title' => 'Server Route', | ||
'type' => CRM_Utils_Type::T_STRING, | ||
]; | ||
$fields['type'] = [ | ||
'title' => 'Type', | ||
'type' => CRM_Utils_Type::T_STRING, | ||
]; | ||
$fields['is_dashlet'] = [ | ||
'title' => 'Dashlet', | ||
'type' => CRM_Utils_Type::T_BOOLEAN, | ||
]; | ||
$fields['is_public'] = [ | ||
'title' => 'Public', | ||
'type' => CRM_Utils_Type::T_BOOLEAN, | ||
]; | ||
} |