On 11 October 2011 13:25, Anthony <[email protected]> wrote:
> Again, if just focused on form validation, I suppose another option would
> be to use an onvalidation function (processed after form validation but
> before db insert).
>
> Anthony
>
>
> On Tuesday, October 11, 2011 7:23:33 AM UTC-4, Anthony wrote:
>>
>> On Tuesday, October 11, 2011 4:04:41 AM UTC-4, spyker wrote:
>>>
>>> I have several tables where there should only be one possible combination
>>> of two uuid-fields per table (mostly many to many links)...
>>
>>
> db.define_table('mytable',
>> Field('field1'),
>> Field('field2', requires=IS_NOT_IN_DB(db(db.**
>> mytable.field1==request.vars.**field1), 'mytable.field2')))
>>
>> That will make sure field2 is unique among the set of records where field1
>> matches the new value of field1 being inserted (so the combination of field1
>> and field2 must be unique). It depends on the values being available in
>> request.vars, so not relevant for non-form inserts (though in that case, I
>> suppose you could create your own request.vars as a hack).
>>
>>
Thanks Anthony. I will probably make use of what you suggested. I did not
know how to involve the two fields in the form-evaluation. This will not
replace the database constraint: tackling this from both the backend and
the user interface.
Regards
Johann
--
May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord! His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a