Am 25.09.2007 um 15:19 schrieb Carl Franks:
On 25/09/2007, Josef Chladek <[EMAIL PROTECTED]> wrote:
hello,
I read that one should not use the DBIC::Unique constraint - so I
eval:
Although it won't be in the core until there's a consistent DBIC
interface, there's nothing to stop you using it for now if you don't
mind using non-cpan modules.
eval {$row->populate_from_formfu( $c->stash->{form} );};
and then check if $@ has the message "Duplicate entry ... for key
'email'"
how would I now set the error for the field 'email' in my form? or
You'll need a constraint especially for that error - you could use a
Callback, as that always passes if you don't provide a callback()
routine - so it won't interfere in any way.
e.g.
---
elements:
- name: email
- constraints:
type: Callback
message: 'Email already taken'
Then, after your test:
if ( $@ =~ m/duplicate entry for key 'email'/i ) {
$form->get_field('email')->get_constraint('Callback')-
>force_error(1);
$form->process;
# then redisplay the form as normal
}
You'll also need to update to svn version 426, as I've just fixed a
bug with force_errors().
Carl
thanks, the line above should read:
$form->get_field('email')->get_constraint('Callback')-
>force_errors(1);
(force_errors instead of force_error), otherwise it works now!
thanks again...
josef
_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu