[Rt-commit] rt branch, 4.2/cf-input-name-sub, repushed
? sunnavy
sunnavy at bestpractical.com
Mon Feb 3 10:43:58 EST 2014
The branch 4.2/cf-input-name-sub was deleted and repushed:
was 054d24f196b724b22af37becf333ade52bdf821f
now 4b21442ed630aa9952dc2e8df97cfbc54dc4410f
1: 054d24f ! 1: 4b21442 refactor cf input name and abstract a sub to get it
@@ -9,13 +9,13 @@
this is complex enough to be wrapped into a sub, not mentioning that you need
to figure out if it's "-Value" or "-Values". some notes:
- * the new sub mimics old naming convension for back compatibility.
+ * the new sub mimics old naming convention for back compatibility.
* old $NamePrefix is still supported(if the new added arg $Name is not set)
* ...-Values-Magic is widened to ...-Magic(so there will be ...-Value-Magic,
...-Upload-Magic, etc because now we simply suffix "-Magic" to the input name)
this commit respects current inconsistent "-Value" vs "-Values" usage, but we
- should fix it in the near futuer:
+ should fix it in the near future:
* cfs with single-value should be named as single "-Value" instead of "-Values"
e.g. Date, DateTime, single Select with render type "List" and maybe also
@@ -31,7 +31,26 @@
+=head2 GetCustomFieldInputName(CustomField => $cf_object, Object => $object, Grouping => $grouping_name)
+
-+Returns the standard custom field input name, which is complement to _ParseObjectCustomFieldArgs
++Returns the standard custom field input name; this is complementary to
++L</_ParseObjectCustomFieldArgs>. Takes the following arguments:
++
++=over
++
++=item CustomField => I<L<RT::CustomField> object>
++
++Required.
++
++=item Object => I<object>
++
++The object that the custom field is applied to; optional. If omitted,
++defaults to a new object of the appropriate class for the custom field.
++
++=item Grouping => I<CF grouping>
++
++The grouping that the custom field is being rendered in. Groupings
++allow a custom field to appear in more than one location per form.
++
++=back
+
+=cut
+
@@ -213,10 +232,20 @@
if ( ( !defined $Default || !length $Default ) && $DefaultsFromTopArguments ) {
my %TOP = %$DECODED_ARGS;
- $Default = $TOP{ $NamePrefix .$CustomField->Id . '-Values' }
-+ $Default = $Name ? $TOP{ $Name } : $TOP{ $NamePrefix .$CustomField->Id . '-Values' }
- || $TOP{ $NamePrefix .$CustomField->Id . '-Value' };
- }
-
+- || $TOP{ $NamePrefix .$CustomField->Id . '-Value' };
++ $Default = $TOP{ $Name } if $Name;
++ # check both -Values and -Value for back compatibility
++ if ( $NamePrefix ) {
++ $Default //= $TOP{ $NamePrefix . $CustomField->Id . '-Values' }
++ // $TOP{ $NamePrefix . $CustomField->Id . '-Value' };
++ }
++ else {
++ my $prefix = GetCustomFieldInputNamePrefix(Object => $Object, CustomField => $CustomField, Grouping => $Grouping );
++ $Default //= $TOP{ $prefix . 'Values' } // $TOP{ $prefix . 'Value' };
++ }
+ }
+
+ my $MaxValues = $CustomField->MaxValues;
@@
}
# The "Magic" hidden input causes RT to know that we were trying to edit the field, even if
@@ -483,7 +512,7 @@
<script type="text/javascript"><!--
jQuery( function () {
- var basedon = jQuery('[name^="<% $NamePrefix . $CustomField->BasedOnObj->id %>-Value"][type!="hidden"]:input:not(.hidden)');
-+ var basedon = jQuery('[name^="<% $BasedOnName || $NamePrefix . $CustomField->BasedOnObj->id . '-Value' |n %>"][type!="hidden"]:input:not(.hidden)');
++ var basedon = jQuery('[name^="'+<% $BasedOnName || $NamePrefix . $CustomField->BasedOnObj->id . '-Value' |n,j %>+'"][type!="hidden"]:input:not(.hidden)');
basedon.each( function() {
var oldchange = jQuery(this).onchange;
jQuery(this).change( function () {
More information about the rt-commit
mailing list