From 9edef7c7e96701ace88c65195b84eb274a570c66 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 29 May 2018 17:16:05 -0400 Subject: [PATCH] Custom Field form tpl and js cleanup --- CRM/Custom/Form/Field.php | 7 +- templates/CRM/Custom/Form/Field.tpl | 538 +++++++++++++--------------- 2 files changed, 249 insertions(+), 296 deletions(-) diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 6b7b8ee79e..8e78331375 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -237,6 +237,7 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { else { $defaults['is_active'] = 1; $defaults['option_type'] = 1; + $defaults['is_search_range'] = 1; } // set defaults for weight. @@ -284,6 +285,8 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $this->assign('gid', $this->_gid); } + $this->assign('dataTypeKeys', self::$_dataTypeKeys); + // lets trim all the whitespace $this->applyFilter('__ALL__', 'trim'); @@ -305,7 +308,6 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $sel = &$this->addElement('hierselect', 'data_type', ts('Data and Input Field Type'), - 'onclick="clearSearchBoxes();custom_option_html_type(this.form)"; onBlur="custom_option_html_type(this.form)";', '   ' ); $sel->setOptions(array($dt, $it)); @@ -515,8 +517,7 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { // is searchable ? $this->addElement('advcheckbox', 'is_searchable', - ts('Is this Field Searchable?'), - NULL, array('onclick' => "showSearchRange(this)") + ts('Is this Field Searchable?') ); // is searchable by range? diff --git a/templates/CRM/Custom/Form/Field.tpl b/templates/CRM/Custom/Form/Field.tpl index ae9d1b4808..8517a9236d 100644 --- a/templates/CRM/Custom/Form/Field.tpl +++ b/templates/CRM/Custom/Form/Field.tpl @@ -23,277 +23,170 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{*Javascript function controls showing and hiding of form elements based on html type.*} -{literal} - -{/literal}
-
{include file="CRM/common/formButtons.tpl" location="top"}
- - - - - - - - + + + + + + + + + +
{$form.label.label} - {if $action == 2} - {include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_field' field='label' id=$id} - {/if} - {$form.label.html}
{$form.data_type.label}{$form.data_type.html} - {if $action neq 4 and $action neq 2} -
{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} - {/if} - {if $action eq 2 and $changeFieldType} -
- - - {ts}Change Input Field Type{/ts} - -
+
{include file="CRM/common/formButtons.tpl" location="top"}
+ + + + + + + + + + {if $form.in_selector} + + + + {/if} - - - {if $form.in_selector} - - - - - {/if} - - - - + + + + - - - - - - - - - - + + + + + + + + + - - = 4 && $form.data_type.value.1.0 neq 'CheckBox' || $form.data_type.value.1.0 neq 'Radio' )}class="hiddenElement"{/if}> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + = 4 && $form.data_type.value.1.0 neq 'CheckBox' || $form.data_type.value.1.0 neq 'Radio' )}class="hiddenElement"{/if}> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - -
{$form.label.label} + {if $action == 2} + {include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_field' field='label' id=$id} + {/if} + {$form.label.html}
{$form.data_type.label}{$form.data_type.html} + {if $action neq 4 and $action neq 2} +
{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} + {/if} + {if $action eq 2 and $changeFieldType} +
+ + + {ts}Change Input Field Type{/ts} + +
+ {/if} +
{$form.in_selector.label}{$form.in_selector.html} {help id="id-in_selector"}
{$form.in_selector.label}{$form.in_selector.html} {help id="id-in_selector"}
{$form.text_length.label}{$form.text_length.html}
{$form.text_length.label}{$form.text_length.html}
- - {* Conditionally show table for setting up selection options - for field types = radio, checkbox or select *} - {include file="CRM/Custom/Form/Optionfields.tpl"} -
-
{$form.group_id.label} - {$form.group_id.html} -   {ts}Advanced Filter{/ts} - {capture assign=searchPreferences}{crmURL p="civicrm/admin/setting/search" q="reset=1"}{/capture} -
{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 Search Preferences - Contact Reference Options to control the fields included in the search results.{/ts} -
{$form.filter.label} - {$form.filter.html} -   {ts}Filter by Group{/ts} +
+ + {* Conditionally show table for setting up selection options - for field types = radio, checkbox or select *} + {include file="CRM/Custom/Form/Optionfields.tpl"} +
+
{$form.group_id.label} + {$form.group_id.html} +   {ts}Advanced Filter{/ts} + {capture assign=searchPreferences}{crmURL p="civicrm/admin/setting/search" q="reset=1"}{/capture} +
{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 Search Preferences - Contact Reference Options to control the fields included in the search results.{/ts} +
{$form.filter.label} + {$form.filter.html} +   {ts}Filter by Group{/ts}
{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"} -
{$form.options_per_line.label}{$form.options_per_line.html|crmAddClass:two}
{$form.start_date_years.label}{$form.start_date_years.html} {ts}years prior to current date.{/ts}
{$form.end_date_years.label}{$form.end_date_years.html} {ts}years after the current date.{/ts}
{$form.date_format.label}{$form.date_format.html}   {$form.time_format.label}  {$form.time_format.html}
{$form.note_rows.label}{$form.note_rows.html}
{$form.note_columns.label}{$form.note_columns.html}
{$form.note_length.label}{$form.note_length.html} {ts}Leave blank for unlimited. This limit is not implemented by all browsers and rich text editors.{/ts}
{$form.weight.label}{$form.weight.html|crmAddClass:two} - {if $action neq 4} - {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} - {/if} -
{$form.default_value.label}{$form.default_value.html}
 {ts}If you want to provide a default value for this field, enter it here. For date fields, format is YYYY-MM-DD.{/ts}
{$form.help_pre.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_field' field='help_pre' id=$id}{/if}{$form.help_pre.html|crmAddClass:huge}
{$form.help_post.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_field' field='help_post' id=$id}{/if}{$form.help_post.html|crmAddClass:huge} - {if $action neq 4} - {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} - {/if} -
{$form.is_required.label}{$form.is_required.html} - {if $action neq 4} -
{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. You can always make the field required when used in a specific Profile form.{/ts} - {/if} -
{$form.is_searchable.label}{$form.is_searchable.html} - {if $action neq 4} -
{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} - {/if} -
{$form.options_per_line.label}{$form.options_per_line.html|crmAddClass:two}
{$form.start_date_years.label}{$form.start_date_years.html} {ts}years prior to current date.{/ts}
{$form.end_date_years.label}{$form.end_date_years.html} {ts}years after the current date.{/ts}
{$form.date_format.label}{$form.date_format.html}   {$form.time_format.label}  {$form.time_format.html}
{$form.note_rows.label}{$form.note_rows.html}
{$form.note_columns.label}{$form.note_columns.html}
{$form.note_length.label}{$form.note_length.html} {ts}Leave blank for unlimited. This limit is not implemented by all browsers and rich text editors.{/ts}
{$form.weight.label}{$form.weight.html|crmAddClass:two} + {if $action neq 4} + {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} + {/if} +
{$form.default_value.label}{$form.default_value.html}
 {ts}If you want to provide a default value for this field, enter it here. For date fields, format is YYYY-MM-DD.{/ts}
{$form.help_pre.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_field' field='help_pre' id=$id}{/if}{$form.help_pre.html|crmAddClass:huge}
{$form.help_post.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_field' field='help_post' id=$id}{/if}{$form.help_post.html|crmAddClass:huge} + {if $action neq 4} + {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} + {/if} +
{$form.is_required.label}{$form.is_required.html} + {if $action neq 4} +
{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. You can always make the field required when used in a specific Profile form.{/ts} + {/if} +
{$form.is_searchable.label}{$form.is_searchable.html} + {if $action neq 4} +
{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} + {/if} +
{$form.is_search_range.label}{$form.is_search_range.html}
{$form.is_active.label}{$form.is_active.html}
{$form.is_view.label}{$form.is_view.html} - {ts}Is this field set by PHP code (via a custom hook). This field will not be updated by CiviCRM.{/ts} -
- {if $action ne 4} -
{include file="CRM/common/formButtons.tpl" location="bottom"}
- {else} -
{include file="CRM/common/formButtons.tpl" location="bottom"}
- {/if} {* $action ne view *} - +
{$form.is_search_range.html}
{$form.is_active.label}{$form.is_active.html}
{$form.is_view.label}{$form.is_view.html} + {ts}Is this field set by PHP code (via a custom hook). This field will not be updated by CiviCRM.{/ts} +
+ {if $action ne 4} +
{include file="CRM/common/formButtons.tpl" location="bottom"}
+ {else} +
{include file="CRM/common/formButtons.tpl" location="bottom"}
+ {/if} +
{literal} {/literal} {* Give link to view/edit choice options if in edit mode and html_type is one of the multiple choice types *} {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 ) ) } - + {/if} -- 2.25.1