PLEASE NOTE THIS WAS AN OPEN TICKET THE PROBLEM HAS SINCE BEEN FIXED!
The solution below is offered as a workaround for those that experience similar issues as described below that don't want to (at present) rebuild, download and re-install their entire component
Hi Admin
I have been working on this for a few days maybe a week now
Have tried various Cook 2.0 builds with various config options over the past week and they all seem to have the same issue
The Issue
I have set the reuse value in save button of a form
It works perfectly when moving between forms related to the same table
but when moving between unrelated itemlayouts the filter value is not applied
I have setup a project called TEST REDIRECT to show what the issue is
and can confirm that the code changes suggested below work for this project.
please feel free to use or modify it to test as needed
My code changes are offered as a "workaround" (there may be more efficient methods or perhaps more secure methods)
but I will leave it up to you to decided the best way to implement it into the Builder and generated script
As i said above it works perfectly when moving between forms related to the same table such as
case 'registrationstepgroup.save':
$this->applyRedirection($result, array(
'com_testredirect.registrationdetail.registrationstepgroup',
'com_testredirect.registrationdetail.registrationstepconfirm'
), array(
'cid[]' => $model->getState('registrationdetail.id'),
'id' => $model->getState('registrationdetail.id')
));
break;
But when you want to pass to a form unrelated to the current table the filter_category is parsed and its value is available but not "preselected" when you move to a new record as shown below
case 'registrationstepconfirm.save':
$this->applyRedirection($result, array(
'com_testredirect.registrationdetail.registrationstepconfirm',
'com_testredirect.groupmembersitem.groupmember'
), array(
'cid[]' => null,
'filter_registration_id' => $model->getState('registrationdetail.id'),
));
break;
When you arrive at the "new record" form the related combo is not "preselected" using the filter_value passed from the previous form.
I believe that it is because the filters are not applied when redirected from tableone_itemlayout to tabletwo_itemlayout
In the model/**
* Method to get the data that should be injected in the form.
*
* @access protected
*
* @return mixed The data for the form.
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_testredirect.edit.groupmembersitem.data', array());
if (empty($data)) {
//Default values shown in the form for new item creation
$data = $this->getItem();
// Prime some default values.
if ($this->getState('groupmembersitem.id') == 0)
{
$jinput = JFactory::getApplication()->input;
$data->id = 0;
$data->params = null;
$data->member_name = null;
$data->group_id = 0;
$data->registration_id = $jinput->get('filter_registration_id',
$this->getState('filter.registration_id'), 'INT');
}
}
return $data;
}
I have made the following changes and can confirm that the filter values are now applied to when redirected to a new record form
$jinput = JFactory::getApplication()->input;
// APPLY THE FILTERS: From the url
$this->setState('filter.registration_id','filter_registration_id', 'INT');
$data->id = 0;
$data->params = null;
$data->member_name = null;
$data->group_id = 0;
// Changed here to get the filter state to work
$data->registration_id = $jinput->get($this->getState('filter.registration_id','filter_registration_id', 'INT'), 'INT');
// OLD CODE
// $data->registration_id = $jinput->get('filter_registration_id', $this->getState('filter.registration_id'), 'INT');
Alternatively the following also works but is untested
$jinput = JFactory::getApplication()->input;
$data->id = 0;
$data->params = null;
$data->member_name = null;
$data->group_id = 0;
// Changed here to get the filter state to work
$data->registration_id = $jinput->get('filter_registration_id', 'INT');
And i can confirm that you are able to parse multiple variables such as
FROM THE CURRENT TABLE ITEM CONTROLLER
// ============================================================================
case 'registrationstepconfirm.save':
$this->applyRedirection($result, array(
'com_testredirect.registrationdetail.registrationstepconfirm',
'com_testredirect.groupmembersitem.groupmember'
), array(
'cid[]' => null,
'filter_registration_id' => $model->getState('registrationdetail.id'),
// Add the second variable here such as
'filter_group_id' => $item->groupname_id'
));
break;
// ==============================================================================
IN THE CURRENT TABLE MODEL
// ==============================================================================
$jinput = JFactory::getApplication()->input;
// APPLY THE FILTERS: From the url
$this->setState('filter.registration_id','filter_registration_id', 'INT');
// add the second variable filter such as below
$this->setState('filter.group_id','filter_group_id', 'INT');
$data->id = 0;
$data->params = null;
$data->member_name = null;
$data->group_id = $jinput->get('filter_registration_id', $this->getState('filter.group_id'), 'INT');
$data->registration_id = $jinput->get('filter_registration_id', $this->getState('filter.registration_id'), 'INT');
// ==============================================================================
Anyhow I guess i can leave this one with you for now...
BTB300