Page 1 of 1

one to one relationship - how to disable add related record

PostPosted: Mon Sep 17, 2012 8:03 pm
by razzetto
Hi Steve.

i'm trying to solve this situation:

i have a one to one relationship between two tables (and, unfortunately, i can't just merge them into one big table).

the relationships.ini file in the source table folder (folder named utenti) is like this:

Code: Select all
[situazione_personale]
situazione_personale.id_utente = "$id_utente"


the destination table, situazione_personale, has only id_utente as a key, so every utente (i.e. 'utenti'.'id_utente' )can have just one related record in the destination table.

now.. my question is.. is it possible to disable the add new related record action if one related record already exists?

with the current behaviour, users can try to add a second record (and xataface tells Record successfully added to situazione_personale relationship.).
Of course, no record is actually added, but it seems to me it's a little confusing (people trying to add a new record, even if not possible, getting the success message and then not seeing the record).

perhaps.. is there a better way to write the relationship? or better to disable the action if there's already a related record?

Thanks,

Paolo

Re: one to one relationship - how to disable add related rec

PostPosted: Mon Sep 24, 2012 9:27 am
by shannah
Add the
Code: Select all
actions:addnew=0

directive to your relationship definition.

http://xataface.com/wiki/relationships.ini_file

-Steve