controller finds eid: 4
i am the model, i have set the id to 4
model KskzEventsModeleditevent set in view: KskzEventsViewEditEvent
view tries to get data from model KskzEventsModeleditevent:
view tries again to get data from model KskzEventsModeleditevent:
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controller library
jimport('joomla.application.component.controller');
class KskzEventsController extends JController
{
function display($cachable = false,$urlparams=false)
{
// call parent behavior
parent::display($cachable);
}
function submit()
{
$document = JFactory::getDocument();
$vType = $document->getType();
$eid = JRequest::getCmd('eid', -1);
die('mama'.$eid);
$vName = JRequest::getCmd('view', 'kskzevents');
JRequest::setVar('view', $vName);
$view = $this->getView($vName, $vType);
$data = JRequest::getVar('jform', array(), 'post', 'array');
print_r($data);
$mName = 'editevent';
if ($model = $this->getModel($mName)) {
// Push the model into the view (as default)
$model->eid = $eid;
die($eid);
$model->set_eid($eid);
$model->data = $data;
$view->setModel($model, true);
if($eid>0) $res = $model->updEvent($eid);
else $res = $model->addEvent();
if ($res==true) echo('event saved');
else echo('event not saved');
}
}
function add()
{
$document = JFactory::getDocument();
$vType = $document->getType();
$vName = JRequest::getCmd('view', 'editevent');
JRequest::setVar('view', $vName);
$eid = JRequest::getCmd('id', -1);
echo('controller finds eid: '.$eid);
$etitle = JRequest::getCmd('title', -1);
$etype = JRequest::getCmd('eventtype','');
$estartdateincl = JRequest::getCmd('startdateincl','');
$enddateincl = JRequest::getCmd('enddateincl','');
$additionalinfo = JRequest::getCmd('additionalinfo','');
$overridedate = JRequest::getCmd('overridedate','');
$forwho = JRequest::getCmd('forwho','');
$place = JRequest::getCmd('place','');
$nationalteam = JRequest::getCmd('nationalteam','');
$view = $this->getView($vName, $vType);
$mName = 'editevent';
if ($model = $this->getModel($mName)) {
// Push the model into the view (as default)
//die($model->get_shit());
$model->eid = $eid;
$model->set_eid($eid);
//die('lala'.$model->eid);
$model->etitle = 'etitle';
//die('test :'.$model->get_title());
$model->etype = $etype;
$model->estartdateincl = $estartdateincl;
$model->enddateincl = $enddateincl;
$model->additionalinfo = $additionalinfo;
$model->overridedate = $overridedate;
$model->forwho = $forwho;
$model->place = $place;
$model->nationalteam = $nationalteam;
$view->setModel($model, true);
echo('<br>model '.$model.' set in view: '.$view);
}
else die('mtf');
parent::display(false);
}
}
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla modelitem library
jimport('joomla.application.component.modelitem');
// Include dependancy of the main model form
jimport('joomla.application.component.modelform');
// import Joomla modelitem library
jimport('joomla.application.component.modelitem');
// Include dependancy of the dispatcher
jimport('joomla.event.dispatcher');
class KskzEventsModeleditevent extends JModelForm
{
public $eid;
public $etitle;
public $etype = '';
public $estartdateincl = '';
public $enddateincl = '';
public $additionalinfo = '';
public $overridedate = '';
public $forwho = '';
public $place = '';
public $nationalteam = '';
public function getForm($data = array(), $loadData = true)
{
$app = JFactory::getApplication('site');
$form = $this->loadForm('com_kskzevents.editevent', 'editevent', array('control' => 'jform', 'load_data' => true));
if (empty($form)) {
return false;
}
return $form;
}
public function addEvent()
{
echo('adding...');
// update click count
$db = $this->getDbo();
$q = 'insert into #__tevent(eventtype,startdateincl,enddateincl,title,additionalinfo,overridedate,forwho,place,nationalteam) ';
$q.= 'values ';
$q.= '("'.$this->data['etype'].'"';
$q.= ',"'.$this->data['estartdateincl'].'"';
$q.= ',"'.$this->data['eenddateincl'].'"';
$q.= ',"'.$this->data['etitle'].'"';
$q.= ',"'.$this->data['eadditionalinfo'].'"';
$q.= ',"'.$this->data['eoverridedate'].'"';
$q.= ',"'.$this->data['eforwho'].'"';
$q.= ',"'.$this->data['eplace'].'"';
$q.= ',"'.$this->data['enationalteam'].'"';
$q.= ')';
$db->setQuery($q);
if (!$db->query($q)) {
JError::raiseError(500, $db->getErrorMsg());
return false;
}
return true;
}
public function updEvent($eid)
{
// update click count
die('nyi');
$db = $this->getDbo();
$q = 'insert into #__paddles(name) values ("'.$this->data['pname'].'")';
$db->setQuery($q);
if (!$db->query($query)) {
JError::raiseError(500, $db->getErrorMsg());
return false;
}
return true;
}
public function set_Title($s) { $this->etitle = $s;}
public function get_Title() {return $this->etitle;}
public function get_eid() { return $this->eid;}
public function getEid() { return $this->eid;}
public function set_eid($i) { $this->eid = $i;echo('<br>i am the model, i have set the id to '.$this->eid);}
public function get_type() { return $this->etype;}
public function get_startdateincl() { return $this->estartdateincl;}
public function get_enddateincl() { return $this->enddateincl;}
public function get_additionalinfo() { return $this->additionalinfo;}
public function get_overridedate() { return $this->overridedate;}
public function get_forwho() {return $this->forwho;}
public function get_place() { return $this->place;}
public function get_nationalteam() { return $this->nationalteam;}
}
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
* HTML View class for the HelloWorld Component
*/
class KskzEventsViewEditEvent extends JView
{
function display($tpl = null)
{
$model = $this->getModel();
$i = $model->get('eid');
echo('<br>view tries to get data from model '.$model.': '.$i);
$i = $this->get('eid');
echo('<br>view tries again to get data from model '.$model.': '.$i);
die('');
$this->assignRef('eventid',$i);
$var1 = 'jaja';
$this->assignRef('var1',$var1);
parent::display($tpl);
}
}
http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Developing_a_Basic_Component
Sry, for the sort answer. But you should really read it first.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/12ixCkv-MO8J.
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
class KskzEventsController extends JController
{
function add()
{
$document = JFactory::getDocument();
$vType = $document->getType();
$vName = JRequest::getCmd('view', 'editevent');
JRequest::setVar('view', $vName);
$eid = JRequest::getCmd('id', -1);
echo('controller finds eid: '.$eid);
$view = $this->getView($vName, $vType);
$mName = 'editevent';
if ($model = $this->getModel($mName)) {
$model->eid = $eid;
$model->set_eid($eid); //STILL OK HERE: debug output = "i am the model, i have set the id to 4 "
$view->setModel($model, true);
echo('<br>model '.$model.' set in view: '.$view);
}
else die('mtf');
parent::display(false);// PROBLEM from here on, when the view displays, the data is not available anymore in the model!
}
class KskzEventsModeleditevent extends JModelForm
{
public $eid; //this shoul be fine? it's a public member var
public function set_eid($i) {
$this->eid = $i;
echo('<br>i am the model, i have set the id to '.$this->eid); //STILL OK HERE: debug output = "i am the model, i have set the id to 4 "
}
public function getEid() { return $this->eid;} //this shoul be fine? it should return the correct value?
}
function display($tpl = null)
{
$model = $this->getModel();
$i = $this->get('eid');
echo('<br>view tries again to get data from model '.$model.': '.$i);
}