M
M
McMike2016-12-16 13:59:16
Yii
McMike, 2016-12-16 13:59:16

Is it possible to set a unique validation rule for 2 fields?

There is a table of dictionary elements (id, dictionary id, key, value). Is it possible to set a validation rule at the framework level for the uniqueness of the id-dictionary + key-element binding?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Maxim Fedorov, 2016-12-16
@McMike

[
    [
        'id_словаря', 
        'key'
    ], 
    'unique', 
    'targetAttribute' => [
        'id_словаря', 
        'key'
    ]
],

M
melnikov_m, 2016-12-16
@melnikov_m

I can offer a bike. Store in the md5 database (id.key) and check it for uniqueness.

D
Dmitry, 2016-12-16
@slo_nik

Good afternoon.
[['id_словаря', 'key'], 'unique']

I
Ilya Karavaev, 2016-12-16
@Quieteroks

The validator has two interesting properties:
targetAttribute and comboNotUnique.
Read the help for these attributes and see the validator source code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question