Hi,
I have 2 input fields, the first input is a prefix and the second is the number, example : prefix -> AB, number ->005.
I pass this parameter by post and server side I'll concat this data separated by -
for example : AB-005.
I want to add to my custom validation class the presence of the prefix field and after the number field. And I want to add the Uniqueness validation on the full string AB-005
to check if I have this in my database. Soooo... I did that
$this->add(
'prefix',
new PresenceOf(
array(
'message' => 'The prefix is required'
)
)
);
$this->add(
'number',
new PresenceOf(
array(
'message' => 'The number is required'
)
)
);
$this->add(
'prefix'.'-'.'number', // <--------- I don't know how I can do that...
new Uniqueness(
array(
'model' => 'Users',
'message' => 'This data should be unique'
)
)
);
Do you know how I can do to concat the prefix and number data to add the Uniqueness validation ?
Edit : replaced $validation by $this