+my $key = dbdef->table($opt{table})->primary_key; #? $opt{primary_key} ||
+
+my $name_col = $opt{name_col};
+
+$opt{hashref} ||= {};
+
+my @records = ();
+if ( $opt{records} ) {
+ @records = @{ $opt{records} };
+} else {
+ @records = qsearch( {
+ 'table' => $opt{table},
+ 'hashref' => $opt{hashref},
+ 'extra_sql' => ( $opt{extra_sql} || '' ),
+ });
+}
+
+unless ( ! $opt{value}
+ or ! exists( $opt{hashref}->{disabled} ) #??
+ or grep { $opt{value} == $_->$key() } @records
+ ) {
+ delete $opt{hashref}->{disabled};
+ $opt{hashref}->{$key} = $opt{value};
+ my $record = qsearchs( {
+ 'table' => $opt{table},
+ 'hashref' => $opt{hashref},
+ 'extra_sql' => ( $opt{extra_sql} || '' ),
+ });
+ push @records, $record if $record;
+}
+
+my @pre_options = $opt{pre_options} ? @{ $opt{pre_options} } : ();