function _civicrm_entity_profile_generate_profile_fapi in CiviCRM Entity 7.2
Generates the FAPI for an individual CiviCRM Profile
Parameters
$profile_id:
Return value
array
1 call to _civicrm_entity_profile_generate_profile_fapi()
- _civicrm_entity_price_set_field_setup_event_registration_form_fapi in modules/
civicrm_entity_price_set_field/ includes/ civicrm_entity_price_set_field.event_registration.inc - Helper function to setup event registration form FAPI
File
- modules/
civicrm_entity_profile/ includes/ civicrm_entity_profile.profile.inc, line 77 - CiviCRM Entity Profile, Profile Form generation and processing, utility functions
Code
function _civicrm_entity_profile_generate_profile_fapi($profile_id, $type = 'event') {
if (!civicrm_initialize()) {
return array();
}
$fields = _civicrm_entity_profile_get_profile_metadata($profile_id, $type);
$contact_entities = array(
'contact',
'address',
'phone',
'email',
'website',
);
$form = array();
if (count($fields)) {
foreach ($fields as $field) {
$widget_info = civicrm_entity_get_field_widget($field, $field['entity']);
if (!empty($widget_info['widget'])) {
// type
$form[$field['name']]['#type'] = $widget_info['widget'];
if ($widget_info['widget'] == 'date_select' || $widget_info == 'date_popup') {
if (module_exists('date_popup')) {
$form[$field['name']]['#type'] = 'date_popup';
}
if (!empty($field['date_format'])) {
$form[$field['name']]['#date_format'] = 'Y-m-d';
}
if (!empty($field['time_format'])) {
if (!empty($form[$field['name']]['#date_format'])) {
$form[$field['name']]['#date_format'] .= ' H:i:s';
}
else {
$form[$field['name']]['#date_format'] = 'H:i:s';
}
}
}
//name
$form[$field['name']]['#title'] = $field['title'];
// options
if (!empty($widget_info['options'])) {
$form[$field['name']]['#options'] = $widget_info['options'];
}
// description
if (!empty($field['help_post'])) {
$form[$field['name']]['#description'] = $field['help_post'];
}
// required
if (!empty($field['api.required']) && $field['api.required'] != "0") {
$form[$field['name']]['#required'] = TRUE;
}
}
}
}
return $form;
}