Hi, in download area you get the new version 1.2.5
Follow these step:
add to file /administrator/components/com_jsn/hepers/fields/selectlist.php (
replace the where of query, see comment)
public static function operations()
{
if(isset($_GET['alias']))
{
// Load Library
JFormHelper::addFieldPath(JPATH_ADMINISTRATOR.'/components/com_jsn/models/fields');
// Load Field Params
$db=JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.*')->from('#__jsn_fields AS a')->where("a.alias = '".$_GET['alias']."'");
$db->setQuery( $query );
$field = $db->loadObject();
$registry = new JRegistry;
$registry->loadString($field->params);
$field->params = $registry;
// Create a form Object with field XML
$form=new JForm('jform',array('control' => 'jform'));
$xml='<form>'."\n";
$xml.=JsnSelectlistFieldHelper::getXml($field);
$xml.="\n".'</form>';
$xml=new SimpleXMLElement($xml);
$form->load($xml);
// Set Where From HTTP
$form->setFieldAttribute($_GET['alias'], 'dboptwhere','state=1 AND catid='.$_GET['catid']); // replace 'state=1 AND catid='.$_GET['catid'] with your query
// Get Input
echo($form->getField($_GET['alias'])->input);
}
}
add this javascript to your jQuery(document).ready() (r
eplace selectAlias1 with your select category alias and selectAlias2 with your select value alias, maybe replace $ with jQuery )
$('#jform_selectAlias1').change(function(){
$.ajax({
url : "index.php?option=com_jsn&view=opField&type=selectlist&alias=selectAlias2&format=raw&catid="+$(this).val(),
success : function (data,state) {
var val=$('#jform_selectAlias2').attr('data-val');
$('#jform_selectAlias2').parent().html(data);
$('#jform_selectAlias2').val(val).attr('data-val',val);
$('#jform_selectAlias2').chosen();
}
})
});
$('#jform_selectAlias1').change();
My test:
I have created select 1 with this parameter:
condition 1: if equal to custom value (empty) hide select 2 // if this field is empty not show select 2
table: #__categories
column value: id
column text: title
sql where: extension='com_content' AND published=1 //because #__categories contains all category not only for article
I have created select 2 with this parameter
table: #__content
column value: id
column text: title
sql where: id=0 //because otherwise you load all record of table before filter by category, this is not a problem but weighs down the page to load