Hi,
I'm having a little trouble with validating fields for uniqueness in the db. I've followed the tutorials but I guess I'm missing something. I'm getting this error on my form: Notice: Invalid rule "unique" passed to Validation, not used. in (unknown) [(unknown)]: add_rule
My code is at http://scrp.at/aEj
Thanks...
@Jelmer did what you said
<code>
if ($fs = Fieldset::instance(get_class($town)))
{
echo $fs->show_errors();
}
$fieldset = Fieldset::factory('status')->add_model($status, null, null);
$fieldset->validation()->add_callable('Myvalidation');
$fieldset->validation()->add_field('name', 'Status Name')
->addRule('unique');
$fieldset->validation()->set_message('unique', 'A record for :name already exists in the database.');
$fieldset->add('name', 'Status Name'), array('type' => 'text'));
$fieldset->add('submit', ' ', array('value' => 'Submit', 'type' => 'submit'));
$fieldset->populate($status, TRUE);
echo $fieldset->build();
</code>
But I'm still getting the error: Notice: Invalid rule "unique" passed to Validation, not used. in (unknown) [(unknown)]: add_rule
any ideas
Thanks...
UPDATE: The error was happening because I had it in my Model validation rules. Removed it from there but now I get a SQL Error when trying to insert a duplicate. So, obviously the validation rule is not running.