+my $msgclass = 'email';
+if ( $cgi->param('msgclass') =~ /^(\w+)$/ ) {
+ $msgclass = $1;
+}
+
+my $fields = [ fields('msg_template') ];
+my $class = "FS::msg_template::$msgclass";
+eval "use $class;";
+if ( $class->extension_table ) {
+ push @$fields, fields($class->extension_table);
+}
+