title: How do I override compare_fields when using Rose::HTML::Form
body: <p>So I'm trying use <a href="https://metacpan.org/pod/Rose%3a%3aHTML%3a%3aForm" rel="nofollow"><code>Rose::HTML::Form</code></a> and I want my fields to appear based on 'rank' rather than by name (the default) .</p>
  
  <p>I've written a comparator subroutine:</p>
  
  <pre><code>sub _order_by_rank {
    my ($self, $one, $two) = @_;
    return $one-&gt;rank &lt;=&gt; $two-&gt;rank;
  };
  </code></pre>
  
  <p>and referenced it in my form constructor:</p>
  
  <pre><code>Rose::HTML::Form-&gt;new(method =&gt; 'post', compare_fields =&gt; \&amp;_order_by_rank);
  </code></pre>
  
  <p>But I am then left with: </p>
  
  <pre><code>Can't call method "name" on unblessed reference at /usr/lib/perl5/site_perl/5.8.8/Rose/HTML/Form/Field/Collection.pm line 405.
  </code></pre>
  
  <p>It seems to call the comparator before I've added anything.</p>
  
  <p>After constructing the form object, I add some fields and then call init_fields:</p>
  
  <pre><code>$form-&gt;add_fields(
      id =&gt; { type =&gt; 'hidden', value =&gt; "", rank =&gt; 0 },
      number =&gt; { type =&gt; 'int', size =&gt; 4, required =&gt; 1, label =&gt; 'Plant Number', rank =&gt; 1 },
      name =&gt; { type =&gt; 'text', size =&gt; 25, required =&gt; 1, label =&gt; 'Plant Name', rank =&gt; 2 },
      ...
    );
  $form-&gt;init_fields;
  </code></pre>
  
  <p>According to the documentation this is something people usually do. What it doesn't explain is <em>how</em> to do it.</p>
  
  <p>Hopefully someone can explain this to me before I have to buy a new keyboard :)</p>