CRM-15789 - Remove civicrm.css styles redundant with jQuery UI
[civicrm-core.git] / templates / CRM / Custom / Form / Field.tpl
CommitLineData
6a488035
TO
1{*
2 +--------------------------------------------------------------------+
39de6fd5 3 | CiviCRM version 4.6 |
6a488035 4 +--------------------------------------------------------------------+
819d0d41 5 | Copyright CiviCRM LLC (c) 2004-2014 |
6a488035
TO
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25*}
26{*Javascript function controls showing and hiding of form elements based on html type.*}
27{literal}
28<script type="text/Javascript">
29function custom_option_html_type( ) {
30 var html_type_name = document.getElementsByName("data_type[1]")[0].value;
31 var data_type_id = document.getElementsByName("data_type[0]")[0].value;
32
33 if ( !html_type_name && !data_type_id ) {
34 return;
35 }
36
37 if ( data_type_id == 11) {
38 toggleContactRefFilter( );
39 } else {
40 cj('#field_advance_filter').hide();
41 cj('#contact_reference_group').hide();
42 }
43
44 if ( data_type_id < 4 ) {
45 if ( html_type_name != "Text" ) {
46 cj("#showoption").show();
47 cj("#hideDefault").hide();
48 cj("#hideDesc").hide();
49 cj("#searchByRange").hide();
50 cj("#searchable").show();
51 } else {
52 cj("#showoption").hide();
53 cj("#hideDefault").show();
54 cj("#hideDesc").show();
55 cj("#searchable").show();
56 }
57 } else {
58 if ( data_type_id == 9 ) {
59 document.getElementById("default_value").value = '';
60 cj("#hideDefault").hide();
61 cj("#searchable").hide();
62 cj("#hideDesc").hide();
63 } else if ( data_type_id == 11 ) {
64 cj("#hideDefault").hide();
65 } else {
66 cj("#hideDefault").show();
67 cj("#searchable").show();
68 cj("#hideDesc").show();
69 }
70 cj("#showoption").hide();
71 }
72
73 var radioOption, checkBoxOption;
74
75 for ( var i=1; i<=11; i++) {
76 radioOption = 'radio'+i;
77 checkBoxOption = 'checkbox'+i
78 if ( data_type_id < 4 ) {
79 if ( html_type_name != "Text") {
80 if ( html_type_name == "CheckBox" || html_type_name == "Multi-Select") {
81 cj("#"+checkBoxOption).show();
82 cj("#"+radioOption).hide();
83 } else {
84 cj("#"+radioOption).show();
85 cj("#"+checkBoxOption).hide();
86 }
87 }
88 }
89 }
90
91 if ( data_type_id < 4 ) {
92 if (html_type_name == "CheckBox" || html_type_name == "Radio") {
93 cj("#optionsPerLine").show();
94 } else {
95 cj("#optionsPerLine").hide();
96 }
97 }
98
99 if ( data_type_id == 5) {
100 cj("#startDateRange").show();
101 cj("#endDateRange").show();
102 cj("#includedDatePart").show();
103 } else {
104 cj("#startDateRange").hide();
105 cj("#endDateRange").hide();
106 cj("#includedDatePart").hide();
107 }
108
109 if ( data_type_id == 0 ) {
110 cj("#textLength").show();
111 } else {
112 cj("#textLength").hide();
113 }
114
115 if ( data_type_id == 4 ) {
116 cj("#noteColumns").show();
117 cj("#noteRows").show();
2f940a36 118 cj("#noteLength").show();
6a488035
TO
119 } else {
120 cj("#noteColumns").hide();
121 cj("#noteRows").hide();
2f940a36 122 cj("#noteLength").hide();
6a488035
TO
123 }
124
125 if ( data_type_id > 3) {
126 cj("#optionsPerLine").hide();
127 }
128
129 {/literal}{if $action eq 1}{literal}
130 clearSearchBoxes( );
131 {/literal}{/if}{literal}
132}
133</script>
134{/literal}
135<div class="crm-block crm-form-block crm-custom-field-form-block">
136<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
137 <table class="form-layout">
138 <tr class="crm-custom-field-form-block-label">
139 <td class="label">{$form.label.label}
140 {if $action == 2}
141 {include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_field' field='label' id=$id}
142 {/if}
143 </td>
144 <td class="html-adjust">{$form.label.html}</td>
145 </tr>
146 <tr class="crm-custom-field-form-block-data_type">
147 <td class="label">{$form.data_type.label}</td>
148 <td class="html-adjust">{$form.data_type.html}
149 {if $action neq 4 and $action neq 2}
150 <br /><span class="description">{ts}Select the type of data you want to collect and store for this contact. Then select from the available HTML input field types (choices are based on the type of data being collected).{/ts}</span>
151 {/if}
152 {if $action eq 2 and $changeFieldType}
153 <br />
154 ( <a href='{crmURL p="civicrm/admin/custom/group/field/changetype" q="reset=1&id=`$id`"}'>{ts}Change Input Field Type{/ts}</a> )
155 <div class='clear'></div>
156 {/if}
157 </td>
158 </tr>
342fdf0a 159 {if $form.in_selector}
5a205b89
PJ
160 <tr class='crm-custom-field-form-block-in_selector'>
161 <td class='label'>{$form.in_selector.label}</td>
b05a0fb6 162 <td class='html-adjust'>{$form.in_selector.html} {help id="id-in_selector"}</td>
5a205b89 163 </tr>
342fdf0a 164 {/if}
5a205b89 165 <tr class="crm-custom-field-form-block-text_length" id="textLength" {if !( $action eq 1 || $action eq 2 ) && ($form.data_type.value.0.0 != 0)}class="hide-block"{/if}>
6a488035
TO
166 <td class="label">{$form.text_length.label}</td>
167 <td class="html-adjust">{$form.text_length.html}</td>
168 </tr>
169
170 <tr id='showoption' {if $action eq 1 or $action eq 2 }class="hide-block"{/if}>
171 <td colspan="2">
172 <table class="form-layout-compressed">
173 {* Conditionally show table for setting up selection options - for field types = radio, checkbox or select *}
174 {include file="CRM/Custom/Form/Optionfields.tpl"}
175 </table>
176 </td>
177 </tr>
178 <tr id='contact_reference_group'>
179 <td class="label">{$form.group_id.label}</td>
180 <td class="html-adjust">
181 {$form.group_id.html}
b7054e52 182 &nbsp;&nbsp;<span><a href="#" onclick="toggleContactRefFilter('Advance'); return false;">{ts}Advanced Filter{/ts}</a></span>
6a488035 183 {capture assign=searchPreferences}{crmURL p="civicrm/admin/setting/search" q="reset=1"}{/capture}
52604b19 184 <div class="messages status no-popup"><div class="icon ui-icon-alert"></div> {ts 1=$searchPreferences}If you are planning on using this field in front-end profile, event registration or contribution forms, you should 'Limit List to Group' or configure an 'Advanced Filter' (so that you do not unintentionally expose your entire set of contacts). Users must have either 'access contact reference fields' OR 'access CiviCRM' permission in order to use contact reference autocomplete fields. You can assign 'access contact reference fields' to the anonymous role if you want un-authenticated visitors to use this field. Use <a href='%1'>Search Preferences - Contact Reference Options</a> to control the fields included in the search results.{/ts}
6a488035
TO
185 </td>
186 </tr>
187 <tr id='field_advance_filter'>
188 <td class="label">{$form.filter.label}</td>
189 <td class="html-adjust">
190 {$form.filter.html}
b7054e52 191 &nbsp;&nbsp;<span><a href="#" onclick="toggleContactRefFilter('Group'); return false;">{ts}Filter by Group{/ts}</a></span>
6a488035 192 <br />
a1252311 193 <span class="description">{ts}Filter contact search results for this field using Contact get API parameters. EXAMPLE: To list Students in group 3:{/ts} "action=get&group=3&contact_sub_type=Student" {docURL page="Using the API" resource="wiki"}</span>
6a488035
TO
194 </td>
195 </tr>
196 <tr class="crm-custom-field-form-block-options_per_line" id="optionsPerLine" {if $action neq 2 && ($form.data_type.value.0.0 >= 4 && $form.data_type.value.1.0 neq 'CheckBox' || $form.data_type.value.1.0 neq 'Radio' )}class="hide-block"{/if}>
197 <td class="label">{$form.options_per_line.label}</td>
198 <td class="html-adjust">{$form.options_per_line.html|crmAddClass:two}</td>
199 </tr>
200 <tr class="crm-custom-field-form-block-start_date_years" id="startDateRange" {if $action neq 2 && ($form.data_type.value.0.0 != 5)}class="hide-block"{/if}>
201 <td class="label">{$form.start_date_years.label}</td>
202 <td class="html-adjust">{$form.start_date_years.html} {ts}years prior to current date.{/ts}</td>
203 </tr>
204 <tr class="crm-custom-field-form-block-end_date_years" id="endDateRange" {if $action neq 2 && ($form.data_type.value.0.0 != 5)}class="hide-block"{/if}>
205 <td class="label">{$form.end_date_years.label}</td>
206 <td class="html-adjust">{$form.end_date_years.html} {ts}years after the current date.{/ts}</td>
207 </tr>
208 <tr class="crm-custom-field-form-block-date_format" id="includedDatePart" {if $action neq 2 && ($form.data_type.value.0.0 != 5)}class="hide-block"{/if}>
209 <td class="label">{$form.date_format.label}</td>
210 <td class="html-adjust">{$form.date_format.html}&nbsp;&nbsp;&nbsp;{$form.time_format.label}&nbsp;&nbsp;{$form.time_format.html}</td>
211 </tr>
212 <tr class="crm-custom-field-form-block-note_rows" id="noteRows" {if $action neq 2 && ($form.data_type.value.0.0 != 4)}class="hide-block"{/if}>
213 <td class="label">{$form.note_rows.label}</td>
214 <td class="html-adjust">{$form.note_rows.html}</td>
215 </tr>
216 <tr class="crm-custom-field-form-block-note_columns" id="noteColumns" {if $action neq 2 && ($form.data_type.value.0.0 != 4)}class="hide-block"{/if}>
217 <td class="label">{$form.note_columns.label}</td>
218 <td class="html-adjust">{$form.note_columns.html}</td>
219 </tr>
2f940a36
NG
220 <tr class="crm-custom-field-form-block-note_length" id="noteLength" {if $action neq 2 && ($form.data_type.value.0.0 != 4)}class="hide-block"{/if}>
221 <td class="label">{$form.note_length.label}</td>
222 <td class="html-adjust">{$form.note_length.html} <span class="description">{ts}Leave blank for unlimited. This limit is not implemented by all browsers and rich text editors.{/ts}</span></td>
223 </tr>
6a488035
TO
224 <tr class="crm-custom-field-form-block-weight" >
225 <td class="label">{$form.weight.label}</td>
226 <td>{$form.weight.html|crmAddClass:two}
227 {if $action neq 4}
228 <span class="description">{ts}Weight controls the order in which fields are displayed in a group. Enter a positive or negative integer - lower numbers are displayed ahead of higher numbers.{/ts}</span>
229 {/if}
230 </td>
231 </tr>
232 <tr class="crm-custom-field-form-block-default_value" id="hideDefault" {if $action eq 2 && ($form.data_type.value.0.0 < 4 && $form.data_type.value.1.0 NEQ 'Text')}class="hide-block"{/if}>
233 <td title="hideDefaultValTxt" class="label">{$form.default_value.label}</td>
234 <td title="hideDefaultValDef" class="html-adjust">{$form.default_value.html}</td>
235 </tr>
236 <tr class="crm-custom-field-form-block-description" id="hideDesc" {if $action neq 4 && $action eq 2 && ($form.data_type.value.0.0 < 4 && $form.data_type.value.1.0 NEQ 'Text')}class="hide-block"{/if}>
237 <td title="hideDescTxt" class="label">&nbsp;</td>
238 <td title="hideDescDef" class="html-adjust"><span class="description">{ts}If you want to provide a default value for this field, enter it here. For date fields, format is YYYY-MM-DD.{/ts}</span></td>
239 </tr>
240 <tr class="crm-custom-field-form-block-help_pre">
241 <td class="label">{$form.help_pre.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_field' field='help_pre' id=$id}{/if}</td>
242 <td class="html-adjust">{$form.help_pre.html|crmAddClass:huge}</td>
243 </tr>
244 <tr class="crm-custom-field-form-block-help_post">
245 <td class="label">{$form.help_post.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_field' field='help_post' id=$id}{/if}</td>
246 <td class="html-adjust">{$form.help_post.html|crmAddClass:huge}
247 {if $action neq 4}
248 <span class="description">{ts}Explanatory text displayed on back-end forms. Pre help is displayed inline on the form (above the field). Post help is displayed in a pop-up - users click the help balloon to view help text.{/ts}</span>
249 {/if}
250 </td>
251 </tr>
252 <tr class="crm-custom-field-form-block-is_required">
253 <td class="label">{$form.is_required.label}</td>
254 <td class="html-adjust">{$form.is_required.html}
255 {if $action neq 4}
256 <br /><span class="description">{ts}Do not make custom fields required unless you want to force all users to enter a value anytime they add or edit this type of record.
257 You can always make the field required when used in a specific Profile form.{/ts}</span>
258 {/if}
259 </td>
260 </tr>
261 <tr id ="searchable" class="crm-custom-field-form-block-is_searchable">
262 <td class="label">{$form.is_searchable.label}</td>
263 <td class="html-adjust">{$form.is_searchable.html}
264 {if $action neq 4}
265 <br /><span class="description">{ts}Can you search on this field in the Advanced and component search forms? Also determines whether you can include this field as a display column and / or filter in related detail reports.{/ts}</span>
266 {/if}
267 </td>
268 </tr>
269 <tr id="searchByRange" class="crm-custom-field-form-block-is_search_range">
270 <td class="label">{$form.is_search_range.label}</td>
271 <td class="html-adjust">{$form.is_search_range.html}</td>
272 </tr>
273 <tr class="crm-custom-field-form-block-is_active">
274 <td class="label">{$form.is_active.label}</td>
275 <td class="html-adjust">{$form.is_active.html}</td>
276 </tr>
277 <tr class="crm-custom-field-form-block-is_view">
278 <td class="label">{$form.is_view.label}</td>
279 <td class="html-adjust">{$form.is_view.html}
280 <span class="description">{ts}Is this field set by PHP code (via a custom hook). This field will not be updated by CiviCRM.{/ts}</span>
281 </td>
282 </tr>
283 </table>
284 {if $action ne 4}
285 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
286 {else}
287 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
288 {/if} {* $action ne view *}
289 </div>
290{literal}
291<script type="text/javascript">
10ede6e5
CW
292 CRM.$(function($) {
293 var $form = $('form.{/literal}{$form.formClass}{literal}'),
294 deprecatedNotice;
295 function deprecatedWidgets() {
296 deprecatedNotice && deprecatedNotice.close && deprecatedNotice.close();
297 switch ($('#data_type_1', $form).val()) {
298 case 'AdvMulti-Select':
299 deprecatedNotice = CRM.alert({/literal}'{ts escape="js"}The old "Advance Multi-Select" widget is being phased out and will be removed in a future version of CiviCRM. "Multi-Select" is the recommended substitute.{/ts}', '{ts escape="js"}Obsolete widget{/ts}'{literal}, 'alert', {expires: 0});
300 break;
301 }
302 }
303 $('#data_type_1', $form).each(deprecatedWidgets).change(deprecatedWidgets);
304 });
305
6a488035
TO
306 //when page is reload, build show hide boxes
307 //as per data type and html type selected.
308 custom_option_html_type( );
309
310 function showSearchRange(chkbox) {
311 var html_type = document.getElementsByName("data_type[1]")[0].value;
312 var data_type = document.getElementsByName("data_type[0]")[0].value;
313
314 if ( ((data_type == 1 || data_type == 2 || data_type == 3) && (html_type == "Text")) || data_type == 5) {
315 if (chkbox.checked) {
316 document.getElementsByName("is_search_range")[0].checked = true;
317 cj("#searchByRange").show();
318 } else {
319 clearSearchBoxes( );
320 }
321 }
322 }
323
324 //should not clear search boxes for update mode.
325 function clearSearchBoxes( ) {
326 document.getElementsByName("is_searchable")[0].checked = false;
327 document.getElementsByName("is_search_range")[1].checked = true;
328 cj("#searchByRange").hide();
329 }
330
331 function toggleContactRefFilter(setSelected) {
332 if ( !setSelected ) {
333 setSelected = cj('#filter_selected').val();
334 } else {
335 cj('#filter_selected').val(setSelected);
336 }
337 if ( setSelected == 'Advance' ) {
338 cj('#contact_reference_group').hide( );
339 cj('#field_advance_filter').show( );
340 } else {
341 cj('#field_advance_filter').hide( );
342 cj('#contact_reference_group').show( );
343 }
344 }
345</script>
346{/literal}
347{* Give link to view/edit choice options if in edit mode and html_type is one of the multiple choice types *}
348{if $action eq 2 AND ($form.data_type.value.1.0 eq 'CheckBox' OR ($form.data_type.value.1.0 eq 'Radio' AND $form.data_type.value.0.0 neq 6) OR $form.data_type.value.1.0 eq 'Select' OR ($form.data_type.value.1.0 eq 'Multi-Select' AND $dontShowLink neq 1 ) ) }
349 <div class="action-link">
350 <a href="{crmURL p="civicrm/admin/custom/group/field/option" q="reset=1&action=browse&fid=`$id`&gid=`$gid`"}">&raquo; {ts}View / Edit Multiple Choice Options{/ts}</a>
351 </div>
352{/if}