<b>Short version</b>: If you have a HTML::FormHandler search form without a &quot;has_field &#39;+item_class&#39;&quot; (there&#39;s no data-base row corresponding to its contents) how to you reach your DBIx::Class schemas to populate a drop-down menu?<div>
<br></div><div><br></div><div><b>Long version</b>: This is in the context of a Catalyst app -- however, I do know this is either FormHandler question or a DBIC question, and not intrinsically a Catalyst question, but... hoping the wise folks here can nudge me in the right direction...</div>
<div><br></div><div>We have several DBIC resultsets including Incident and Country. The Incident record has this relationship:</div><div><font class="Apple-style-span" color="#339999">__PACKAGE__-&gt;belongs_to( &#39;country&#39; =&gt; &#39;Incident::Schema::DB::Result::Country&#39; );</font></div>
<div><br></div><div>(And the country schema <font class="Apple-style-span" color="#339999">has_many</font> incidents, of course)</div><div><br></div><div>For the CRUD form related to the actual incident table, we have a matching HTML::FormHandler package with its</div>
<div><font class="Apple-style-span" color="#339999">has &#39;+item_class&#39;</font></div><div>as expected. This makes it easy to create a </div><div><font class="Apple-style-span" color="#339999">sub options_country {</font></div>
<div><font class="Apple-style-span" color="#339999">  my $self = shift;</font></div><div><font class="Apple-style-span" color="#339999">  return unless $self-&gt;schema;</font></div><div><span class="Apple-style-span" style="color: rgb(51, 153, 153); ">  my $rs = $self-&gt;schema-&gt;resultset(&#39;Country&#39;);</span></div>
<div><span class="Apple-style-span" style="color: rgb(51, 153, 153); ">  #...</span></div><div><font class="Apple-style-span" color="#339999">}</font></div><div>subroutine for the form, for populating a country drop-down menu in the HTML.</div>
<div><br></div><div>But!</div><div><br></div><div>For the SEARCH form, we are not interested in CRUD, plus we have extra fields (for example, we want the user to be able to bracket dates with a start-field and an end-field) so there&#39;s no one-to-one correlation with the database table -- meaning there&#39;s no &quot;item_class&quot; for the search form. And hence no schema to rely on.</div>
<div><br></div><div>What we&#39;re looking for now -- unless there&#39;s a better more obvious paradigm -- is a way to get from an instance of the schema-object, back to the resultset, for searching.</div><meta charset="utf-8"><div>
<font class="Apple-style-span" color="#339999">sub options_country {</font></div><div><font class="Apple-style-span" color="#339999">  my $self = shift; # note $c is not available here :(</font></div><div><font class="Apple-style-span" color="#339999">  # $self-&gt;schema will be UNDEF here</font></div>
<div><font class="Apple-style-span" color="#339999">  my $obj = Spill::Schema::DB::Result::Country-&gt;new; # Hard-wired, yes, is there a better way?</font></div><div><font class="Apple-style-span" color="#339999">  my $rs = $obj-&gt;???</font></div>
<div><font class="Apple-style-span" color="#339999">  # ?</font></div><div><font class="Apple-style-span" color="#339999">}</font></div><div><br></div><div>I&#39;ve looked at </div><div>- $obj-&gt;result_source (Can&#39;t call method &quot;resolve&quot; on an undefined valued in DBIx/Class/Row) </div>
<div>- $obj-&gt;result_source_instance-&gt;resultset (Can&#39;t call method &quot;default_resultset_attributes&quot; on an undef value in DBIx/Class/ResultSource)</div><div>- $obj-&gt;result_source_instance-&gt;resultset_class-&gt;search({},{}) (Can&#39;t use string as a HASH ref in DBIx/Class/ResultSet)</div>
<div>and a couple other dead ends.</div><div><br></div><div>It&#39;s likely to be something obvious I&#39;ve overlooked. :( Suggestions?</div><div><br>-- <br>The first step towards getting somewhere is to decide that you are not going to stay where you are.  -- J.P.Morgan<br>

</div>