{*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
+<div class="crm-profile-name-{$ufGroupName}">
+{crmRegion name=profile-form-`$ufGroupName`}
+
{* Profile forms when embedded in CMS account create (mode=1) or
cms account edit (mode=8) or civicrm/profile (mode=4) pages *}
{if ($context eq 'multiProfileDialog')}
{literal}
<script type="text/javascript">
-cj(function() {
+cj(function($) {
+ $('#profile-dialog .crm-container-snippet #Edit').validate(CRM.validate.params);
var formOptions = {
- beforeSubmit: proccessMultiRecordForm //pre-submit callback
+ success: checkResponse // post-submit callback
};
//binding the callback to snippet profile form
- cj('.crm-container-snippet #Edit').ajaxForm(formOptions);
+ $('.crm-container-snippet #Edit').ajaxForm(formOptions);
});
-// pre-submit callback
-function proccessMultiRecordForm(formData, jqForm, options) {
- var queryString = cj.param(formData);
- queryString = queryString + '{/literal}{$urlParams}{literal}' + '&snippet=1';
-
- if (cj('#profile-dialog')) {
- var postUrl = {/literal}"{crmURL p='civicrm/profile/edit' h=0 }"{literal};
- var response = cj.ajax({
- type: "POST",
- url: postUrl,
- async: false,
- data: queryString,
- dataType: "json",
-
- }).responseText;
-
- //if there is any form error show the dialog
- //else redirect to post url
- if (cj(response).find('.crm-error').html()) {
- cj('#profile-dialog').show().html(response);
- }
- else {
- window.location = '{/literal}{$postUrl}{literal}';
- }
-
- // here we could return false to prevent the form from being submitted;
- // returning anything other than false will allow the form submit to continue
- return false;
+// post-submit callback
+function checkResponse(responseText, statusText, xhr, $form) {
+ //if there is any form error show the dialog
+ //else redirect to post url
+ if (!cj(responseText).find('.crm-error').html()) {
+ window.location.href = '{/literal}{$postUrl}{literal}';
}
-}
+}
</script>
{/literal}
+{include file="CRM/Form/validate.tpl"}
{/if}
{if $deleteRecord}
<div class="messages status no-popup">
{/foreach}
</tr>
</table>
- {if $field.html_type eq 'Radio' and $form.formName eq 'Edit' and $field.is_view neq 1 }
- <span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('{$n}', '{$form.formName}'); return false;">{ts}clear{/ts}</a>)</span>
- {/if}
{/strip}
</div>
<div class="clear"></div>
{else}
{$form.$n.html}
{/if}
- {if (($n eq 'gender') or ($field.html_type eq 'Radio' and $form.formName eq 'Edit' and $field.is_required neq 1)) and
- ($field.is_view neq 1)}
- <span class="crm-clear-link">(<a href="#" title="unselect" onclick="unselectRadio('{$n}', '{$form.formName}'); return false;">{ts}clear{/ts}</a>)</span>
- {elseif $field.html_type eq 'Autocomplete-Select'}
+ {if $field.html_type eq 'Autocomplete-Select'}
{if $field.data_type eq 'ContactReference'}
{include file="CRM/Custom/Form/ContactReference.tpl" element_name = $n}
- {else}
- {include file="CRM/Custom/Form/AutoComplete.tpl" element_name = $n}
{/if}
{/if}
{/if}
{/if}
{/if}{* end of main if field name if *}
{/foreach}
- </div><!-- end form-layout-compressed for last profile --> {* closing main form layout div when all the fields are built*}
-
-
+
{if $isCaptcha && ( $mode eq 8 || $mode eq 4 || $mode eq 1 ) }
{include file='CRM/common/ReCAPTCHA.tpl'}
<script type="text/javascript">cj('.recaptcha_label').attr('width', '140px');</script>
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}{$blockNo}{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.sortName + {/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 *}