) {
$this->addElement('hidden', 'qfKey', $this->controller->_key);
$this->assign('qfKey', $this->controller->_key);
+
}
+ // _generateQFKey suppresses the qfKey generation on form snippets that
+ // are part of other forms, hence we use that to avoid adding entryURL
+ if ($this->controller->_generateQFKey && $this->controller->_entryURL) {
+ $this->addElement('hidden', 'entryURL', $this->controller->_entryURL);
+ }
$this->buildQuickForm();
self::$_template->assign_by_ref($var, $value);
}
+ /**
+ * appends values to template variables
+ *
+ * @param array|string $tpl_var the template variable name(s)
+ * @param mixed $value the value to append
+ * @param bool $merge
+ */
+ function append($tpl_var, $value=NULL, $merge=FALSE) {
+ self::$_template->append($tpl_var, $value, $merge);
+ }
+
+ /**
+ * Returns an array containing template variables
+ *
+ * @param string $name
+ * @param string $type
+ * @return array
+ */
+ function get_template_vars($name=null) {
+ return self::$_template->get_template_vars($name);
+ }
+
function &addRadio($name, $title, &$values, $attributes = NULL, $separator = NULL, $required = FALSE) {
$options = array();
if (empty($attributes)) {
// event form stores as an indexed array, contribution form not so much...
$tempID = $this->_params[0]['select_contact_id'];
}
+
// force to ignore the authenticated user
- if ($tempID === '0') {
+ if ($tempID === '0' || $tempID === 0) {
+ // we set the cid on the form so that this will be retained for the Confirm page
+ // in the multi-page form & prevent us returning the $userID when this is called
+ // from that page
+ // we don't really need to set it when $tempID is set because the params have that stored
+ $this->set('cid', 0);
return $tempID;
}
'id_field' => 'select_contact_id',
'field_text' => ts('Select Contact'),
'show_hide' => TRUE,
- 'show_text' => ts('to select someone already in our database'),
- 'hide_text' => ts('to clear this person and fill the form in for someone else'),
+ 'show_text' => ts('to select someone already in our database.'),
+ 'hide_text' => ts('to clear this person\'s information, and fill the form in for someone else'),
'url' => array('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1'),
'max' => civicrm_api3('setting', 'getvalue', array(
'name' => 'search_autocomplete_count',
if(0 < (civicrm_api3('contact', 'getcount', array('check_permissions' => 1)))) {
$this->addElement('text', $autoCompleteField['name_field'] , $autoCompleteField['field_text']);
- $this->addElement('hidden', $autoCompleteField['id_field'], '', array('id' => $autoCompleteField['id_field'])); $this->assign('selectable', $autoCompleteField['id_field']);
+ $this->addElement('hidden', $autoCompleteField['id_field'], '', array('id' => $autoCompleteField['id_field']));
+ $this->assign('selectable', $autoCompleteField['id_field']);
- CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/common/AutoComplete.js')
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/AutoComplete.js')
->addSetting(array(
'form' => array('autocompletes' => $autoCompleteField),
'ids' => array('profile' => $profiles),
$this->addAutoSelector($profiles);
}
}
+
+ /**
+ * Set default values on form for given contact (or no contact defaults)
+ * @param mixed $profile_id (can be id, or profile name)
+ * @param integer $contactID
+ */
+ function getProfileDefaults($profile_id = 'Billing', $contactID = NULL) {
+ try{
+ $defaults = civicrm_api3('profile', 'getsingle', array(
+ 'profile_id' => (array) $profile_id,
+ 'contact_id' => $contactID,
+ ));
+ return $defaults;
+ }
+ catch (Exception $e) {
+ // the try catch block gives us silent failure -not 100% sure this is a good idea
+ // as silent failures are often worse than noisy ones
+ return array();
+ }
+ }
}