Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

n:n saving function 12 Sep 2016 14:23 #14523

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
Hi all

So I have a table JOB which has a 1:n relationship

jobs
|
jobsexperts
|
experts

so when you are in a job, you have the usual multi select of all the experts which I can select from

Here is my issue

when an expert(s) is added to this job and the job is saved, i want to fire an email to those users.. now.. the email bit is EASY, getting their ID and email is, but where is the save function that controls that multiselect so I can add the mailer code to the process?

I have looked in the jobsexpert model but there is no save function, and now sure how the job save function even reference that multselect
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla

Please Log in or Create an account to join the conversation.

n:n saving function 12 Sep 2016 19:45 #14525

If I have reverse enginered it correctly:
- save is a controller function, it is in you job controller file.
- that is a decendant from the item.php in the classes/controller folder in the admin part of your component.
- in there, somewhere is: if (!$model->save($validData))
- the model, in this case, you can find in classes/model/item.php, look for the save function.
- In there is: $this->syncRelation($name, $data[$name]);
- the syncRelation function does the saving, it is also in the item.php

What you can do to get the experts:
Check the controller for job and look for the save function.
In there, there is a bit:
			//Get the model through postSaveHook()
			if ($this->model)
			{
				$model = $this->model;
				$item = $model->getItem();	
				$model->loadRelations('classes');
				$model->loadRelations('options');
			}

You can fork the controller and function and change above to
			//Get the model through postSaveHook()
			if ($this->model)
			{
				$model = $this->model;
				$item = $model->getItem();	
				$model->loadRelations('experts');
			}
Then you will have the experts and you can create a loop or so to add them to the recipients. ($item->experts is probably a array of objects)

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.068 seconds

Freakin' Awesome!!! J-Cook is simply awesome - whether you're a highly experienced developer or complete novice whether you're building a small inventory component or a complete community solution! The beauty comes from a fast slick and reliable platform that readily provides developers with everything they'll need to build the backbone of a solid and secure component with wizards for authoring access publishing aliasing created/modified by dates... you name it COOK provides it! J-Cook really surpasses all of the 'competition' as far as MVC tools are concerned! Try love it and get cooking!
learnthrusong (JED)
          

Get Started