groovy - How to create and save data on the go in Grails? -


i have 2 domain classes

expenditure

class expenditure {    date date    supplier supplier    string particular    bigdecimal amount } 

supplier

class supplier {    string name    string address     static hasmany = [expenditures: expenditure] } 

what happening when create new expenditure, enter supplier list of suppliers in supplier class. when supplier not exist, have create first , select when creating expenditure.

what want that, when enter supplier looked up, , when not found, created on go (when saving expenditure instance) without me having create first in supplier table , come expenditure complete form.

how can achieve this?

what want that, when enter supplier looked up, , when not found, created on go

one option have 1 of these...

supplier.findorcreatebyname('some name goes here') supplier.findorcreatebynameandaddress('some name goes here', 'some address goes here') 

there findorsaveby... counterparts work if supplying enough search criteria create save-able instance.

i hope helps.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -