Hello ,
I have the following code in my calc field:
--------------------------------------------------------------------------
// Get a db connection.
$myDb = \Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
// Create a new query object.
$myQuery = $myDb->getQuery(true);
$myQuery
->select(array('subactivity.subactivity_name'))
->from('subactivity')
->join('INNER', 'intemgroup1 ON intemgroup1.subactivity_name=subactivity.id')
->join('INNER', 'projects ON projects.id=intemgroup1.project_name')
->join('INNER', 'activities ON activities.id=intemgroup1.activity_name')
->where('projects.project_name = ' . $myDb->quote('{overlapping___project_1}') )
->where('activities.activity_name = ' . $myDb->quote('{overlapping___activity_1}'));
// Assign the query to the db
$myDb->setQuery($myQuery);
// Load the results as an array of objects.
$rows = $myDb->loadObjectList();
$list = array();
foreach ($rows as $row)
{ $list[] = "<option style=\"max-width=100px;\" value=\"{$row->id}\">" . $row->subactivity_name . "</option>";
}
return '<select style="width: 400px;height: 150px;word-wrap: break-word;word-break: break-all; white-space: normal;" name="subactivity">' . implode($list) . '</select>';
--------------------------------------------------------------------------
It all works more or less fine in the form. The problem is that after i click the submit button and the list shows up the formed data is saved and entered in the database with the whole code not just the value of the selected item. So at the list I get again the dropdown menu from the calc field rather then just the value selected in the form.
Any advise suggestion how to resolve it ? I have attached screenshot of the list which shows the calc field as dropdown rather then the value selected in the form dropdown .
I have the following code in my calc field:
--------------------------------------------------------------------------
// Get a db connection.
$myDb = \Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
// Create a new query object.
$myQuery = $myDb->getQuery(true);
$myQuery
->select(array('subactivity.subactivity_name'))
->from('subactivity')
->join('INNER', 'intemgroup1 ON intemgroup1.subactivity_name=subactivity.id')
->join('INNER', 'projects ON projects.id=intemgroup1.project_name')
->join('INNER', 'activities ON activities.id=intemgroup1.activity_name')
->where('projects.project_name = ' . $myDb->quote('{overlapping___project_1}') )
->where('activities.activity_name = ' . $myDb->quote('{overlapping___activity_1}'));
// Assign the query to the db
$myDb->setQuery($myQuery);
// Load the results as an array of objects.
$rows = $myDb->loadObjectList();
$list = array();
foreach ($rows as $row)
{ $list[] = "<option style=\"max-width=100px;\" value=\"{$row->id}\">" . $row->subactivity_name . "</option>";
}
return '<select style="width: 400px;height: 150px;word-wrap: break-word;word-break: break-all; white-space: normal;" name="subactivity">' . implode($list) . '</select>';
--------------------------------------------------------------------------
It all works more or less fine in the form. The problem is that after i click the submit button and the list shows up the formed data is saved and entered in the database with the whole code not just the value of the selected item. So at the list I get again the dropdown menu from the calc field rather then just the value selected in the form.
Any advise suggestion how to resolve it ? I have attached screenshot of the list which shows the calc field as dropdown rather then the value selected in the form dropdown .
Attachments
Last edited: