+my $name = $opt{'element_name'} || $opt{'field'} || 'ruleconditionnum';
+#my $id = $opt{'id'} || 'contactnum';
+my $id = $opt{'id'} || $opt{'field'} || 'ruleconditionnum';
+
+my $curr_value = $opt{'curr_value'} || $opt{'value'};
+
+my $onchange = '';
+if ( $opt{'onchange'} ) {
+ $onchange = $opt{'onchange'};
+ $onchange .= '(what)' unless $onchange =~ /\(\w*\);?$/;
+}
+
+my $cgp_rule_condition;
+if ( $curr_value ) {
+ $cgp_rule_condition = qsearchs('cgp_rule_condition',
+ { 'ruleconditionnum' => $curr_value } );
+} else {
+ $cgp_rule_condition = new FS::cgp_rule_condition {};
+}
+
+my $conditionname = scalar($cgi->param($name.'_conditionname'))
+ || $cgp_rule_condition->conditionname;
+
+my @op = &$cond2op($conditionname);