I'm trying to develop the reviews component descripted in this book but I'm a problem.
I'm in the chapter 3 (page 36) and I followed all the steps for build the reviews class anche the admin side code for create form and store data. The situation is this (I'm trying to crate the component in my language, italiano) the file with the code is file administrator/components/com_recensioni/admin.recensioni.php
Code: Select all
<?php
defined ('_JEXEC') or die ('Restricted access');
require_once (JApplicationHelper::getPath('admin_html'));
JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');
switch ($task) {
case 'add':
modificaRecensione ($option);
break;
case 'save':
salvaRecensione($option);
break;
}
function modificaRecensione ($option) {
$row =& JTable::getInstance('recensione','Tabella');
$lists = array();
$prenotazioni = array(
'0' => array('Value' => 'Nessuna', 'text' => 'Nessuna'),
'1' => array('Value' => 'Accettata', 'text' => 'Accettata'),
'2' => array('Value' => 'Suggerita', 'text' => 'Suggerita'),
'3' => array('Value' => 'Richiesta', 'text' => 'Richiesta')
);
$lists['prenotazioni'] = JHtml::_('select.genericList', $prenotazioni, 'prenotazioni', 'class="inputbox" '. '','value','text',$row->prenotazioni);
$lists['fumatori'] = JHtml::_('select.booleanlist', 'fumatori', 'class="inputbox"', $row->fumatori);
$lists['pubblicato'] = JHtml::_('select.booleanlist','pubblicato','class="inputbox"', $row->pubblicato);
HTML_recensioni::modificaRecensione($row, $lists, $option);
}
function salvaRecensione($option) {
global $mainframe;
$row =& JTable::getInstance('recensione', 'Tabella');
if (!$row->bind(JRequest::get('post'))){
echo "<script> alert('".$row->getError()."');
window.history.go(-1);
</script>\n";
exit();
}
$row->presentazione = JRequest::getVar( 'presentazione', '', 'post', 'string', JREQUEST_ALLOWRAW );
$row->recensione = JRequest::getVar( 'recensione', '', 'post','string', JREQUEST_ALLOWRAW );
if(!$row->data_recensione)
$row->data_recensione = date('%Y-%m-%d');
if (!$row->store()){
echo "<script> alert('".$row->getError()."');
window.history.go(-1); </script>\n";
exit();
}
$mainframe->redirect('index.php?option=' .$option, 'Recensione Salvata');
}
?>
I've also created the admin.recensioni.html.php and It works fine in my back-end.
The problem is: I can save my data in the table of database except for then 'prenotazioni' (reservations, in the book) listbox. Joomla doesn't return me errors but in the Apache's log file I obtain this error:
PHP Notice: Undefined index: value in /var/www/html/test.studioartifex/joomla/libraries/joomla/html/html/select.php on line 76
I need help! Please! And sorry for my english