⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Dynamic $where condition in set_relation_n_n



larasmith

larasmith
  • profile picture
  • Member

Posted 14 August 2014 - 15:21 PM

Hello to all!

 

I hope that all is well. Sir web-johny suggested that I post this here. I'm desperately needing your help to create a "Dynamic $where condition in set_relation_n_n". To give you a better view of what I am trying to create here is an image of it:

 

tanong.png

 

Currently here's my code: (In the Controller this is a callback)

function tos_CBae_selFunc()
{
	return '
		<script type="text/javascript">
			$(document).ready(function(){
				$("#secret_field_box").hide();
				$("#field-tos_prog_id").change(function() {
					alert("Prog ID selected");	// xxx				
					$.get("/lara/merge/GetDrop",{drop:this.value},
					function (result){
						$("#Function_field_box").load(" #field-Functions");
					})																			
				})
			})				
		</script>
		' ;	
}

Also in the controller: (this is the one that generates the set_relation_n_n for the field: functions)

$where = array('funct_prog_id'=> $_SESSION['dropval']);
$crud->set_relation_n_n('Functions', 'tbltos_funct', 'tblfunction', 'tos_id', 'funct_id', "{funct_Name}-{funct_prog_id}", 'priority',$where);

Here's the code in the "GetDrop.php":

<?php
session_start();
class GetDrop extends MY_Controller {	
 	public function index()
		{
			$_SESSION['dropval'] =  $_GET['drop'];		  
		}		
	}
?>

The current output is obtained only if a page reload is done... which is not applicable to the output that I need. What I need is the auto loading of the needed values upon selecting a value from the program field.

 

Please help me to create this one or if there are any other better approach to this please suggest. I've done my reasearch and tried other methods but still cannot make this work. Sorry to disturb but I really need your help.   :rolleyes:

 

Thank you very much!  :)

 


ryuusoultaker

ryuusoultaker
  • profile picture
  • Member

Posted 10 September 2014 - 03:38 AM

I kinda need to solve this situation too, i need exact dynamic $where condition like you do there..can some one help us with some explanation >,<


larasmith

larasmith
  • profile picture
  • Member

Posted 11 September 2014 - 02:13 AM

Hello there ryuusoultaker!

 

The Dynamic $where condition in set_relation_n_n is NOT POSSIBLE because it is assigned before the creation of the crud, but i created a work around to do that... please check this out:

/topic/2682-dependent-drop-down-with-multiselect/

 

Happy GCng!  :D  :ph34r: