if (in_array($profile['name'], $profiles)) {
$links[] = array(
'label' => $profile['title'],
- 'url' => CRM_Utils_System::url('civicrm/profile/create', 'reset=1&gid=' . $id),
+ 'url' => CRM_Utils_System::url('civicrm/profile/create', 'reset=1&context=dialog&&gid=' . $id),
'name' => $profile['name'],
);
}
'isDefault' => TRUE,
);
- if ($this->_context != 'dialog') {
- $buttons[] = array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- 'isDefault' => TRUE,
- );
- }
+ $buttons[] = array(
+ 'type' => 'cancel',
+ 'name' => ts('Cancel'),
+ 'isDefault' => TRUE,
+ );
$this->addButtons($buttons);
$sortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_id, 'sort_name');
$this->ajaxResponse['label'] = $sortName;
- // this is special case when we create contact using Dialog box
- if ($this->_context == 'dialog') {
- //replace the session stack for redirecting user to contact summary if new contact is created.
- $contactViewURL = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_id}", FALSE, NULL, FALSE);
- $session = CRM_Core_Session::singleton();
- $session->replaceUserContext($contactViewURL);
-
- $returnArray = array(
- 'contactID' => $this->_id,
- 'displayName' => $displayName,
- 'sortName' => $sortName,
- 'newContactSuccess' => TRUE,
- );
-
- echo json_encode($returnArray);
- CRM_Utils_System::civiExit();
- }
-
- //for delete record handling
- if (empty($_POST[$this->_deleteButtonName])) {
+ // When saving (not deleting) and not in an ajax popup
+ if (empty($_POST[$this->_deleteButtonName]) && $this->_context != 'dialog') {
CRM_Core_Session::setStatus(ts('Your information has been saved.'), ts('Thank you.'), 'success');
}
cj('#selector tr:odd ').addClass('even-row');
});
{/literal}
-{if $context eq 'dialog'}
-{literal}
- var options = {
- beforeSubmit: showRequest
- };
-
- // bind form using 'ajaxForm'
- cj('#Edit').ajaxForm( options );
-
- // FIXME - this is improper use of jquery.form
- // Do not use this code as an example
- function showRequest(formData, jqForm, options) {
- // formData is an array; here we use $.param to convert it to a string to display it
- // but the form plugin does this for you automatically when it submits the data
- var queryString = cj.param(formData);
- queryString = queryString + '&snippet=5&gid=' + {/literal}"{$profileID}"{literal};
- var postUrl = {/literal}"{crmURL p='civicrm/profile/create' h=0 }"{literal};
- var blockNo = {/literal}{if $blockNo}{$blockNo}{else}null{/if}{literal};
- var prefix = {/literal}"{$prefix}"{literal};
- var response = cj.ajax({
- type: "POST",
- url: postUrl,
- async: false, // FIXME
- data: queryString,
- dataType: "json",
- success: function( response ) {
- if ( response.newContactSuccess ) {
- cj('#' + prefix + 'contact_' + blockNo ).val( response.sortName ).focus( );
- if ( typeof(allowMultiClient) != "undefined" ) {
- if ( allowMultiClient ) {
- cj('#' + prefix + 'contact_' + blockNo).tokenInput("add", {id: response.contactID, name: response.sortName });
- }
- }
- cj('input[name="' + prefix + 'contact_select_id[' + blockNo +']"]').val( response.contactID );
- CRM.alert(response.displayName + {/literal}'{ts escape="js"} has been created.{/ts}', '{ts escape="js"}Contact Saved{/ts}'{literal}, 'success');
- cj('#contact-dialog-' + prefix + blockNo ).dialog('close');
- }
- }
- }).responseText;
-
- cj('#contact-dialog-' + prefix + blockNo).html( response );
-
- // FIXME - we have used jquery.form very incorrectly
- // and are now preventing it from doing what it's supposed to do
- return false;
- }
-
-{/literal}
-{/if}
-{literal}
</script>
-{/literal}
{/crmRegion}
</div> {* end crm-profile-NAME *}