import rt 3.8.9
[freeside.git] / rt / html / Elements / EditCustomField
index d2398c9..85641ef 100644 (file)
@@ -2,7 +2,7 @@
 %# 
 %# COPYRIGHT:
 %#  
-%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC 
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC 
 %#                                          <jesse@bestpractical.com>
 %# 
 %# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
 %# 
 %# You should have received a copy of the GNU General Public License
 %# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
 %# 
 %# 
 %# CONTRIBUTION SUBMISSION POLICY:
 %# END BPS TAGGED BLOCK }}}
 <%INIT>
 my $Values;
-if ($Object) {
+if ($Object and $Object->id) {
     $Values = $Object->CustomFieldValues($CustomField->id);
     $Values->Columns( qw( id CustomField ObjectType ObjectId Disabled Content ContentType ContentEncoding ) );
     $NamePrefix ||= join('-', 'Object', ref($Object), $Object->Id, 'CustomField', '');
+} elsif (not $Default) {
+    my %TOP = $m->request_args;
+    $Default = $TOP{ $NamePrefix .$CustomField->Id . '-Values' }
+            || $TOP{ $NamePrefix .$CustomField->Id . '-Value' };
 }
 my $Type = $CustomField->Type;
 
@@ -63,10 +69,14 @@ if ($MaxValues == 1 and $Object and $Values) {
 }
 # The "Magic" hidden input causes RT to know that we were trying to edit the field, even if 
 # we don't see a value later, since browsers aren't compelled to submit empty form fields
-$m->out("\n".'<input type="hidden" name="'.$NamePrefix.$CustomField->Id.'-Values-Magic" value="1">'."\n");
+$m->out("\n".'<input type="hidden" class="hidden" name="'.$NamePrefix.$CustomField->Id.'-Values-Magic" value="1" />'."\n");
+
+my $EditComponent = "EditCustomField$Type";
+$m->comp('/Elements/Callback', _CallbackName => 'EditComponentName', Name => \$EditComponent, CustomField => $CustomField, Object => $Object );
+$EditComponent = "EditCustomField$Type" unless $m->comp_exists($EditComponent);
 
 return $m->comp(
-    "EditCustomField$Type",
+    $EditComponent,
     %ARGS,
     Rows => $Rows,
     Cols => $Cols,