Does anyone have some example of the code they use to enforce a unique value in a column using Catalyst and FormFu? I have the database set up to not allow duplicate values, but I don't know if it's unique until I get the error back. This can't be the way.

I am sort of assuming that I would need a transformer on an element that takes the value and runs a query against the database to see if it is there or not? I'm not sure how that code would work or if it is even the right way to go about it.

   transformers:
       - type: Callback
         callback: MyApp::Utils::is_unique


sub is_unique {
   my ( $value, $field_value ) = @_;

   return $c->model(__PACKAGE__)->find({username=>$field_value}) ? 0:1;
}


_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to