سؤال

in the moment I'm trying to save the following table:

http://img5.fotos-hochladen.net/uploads/tabelle1k6xegf4tm.jpg

Only the -fields needs to be saved when I click on the blue button below the table. My problem: I'm new at joomla and dont know to how to save this. Am I using the right Classes? Is it possible to solve this by an table-class? Maybe someone can send me an component where something like this is solved? Or can give me the right code samples?

Here you can find what I've done:

class TippspielModelTippview extends JModelList 
    { 
        protected function getListQuery() 
        { 
            //Erstelle ein neues Query-Objekt 
            $db= JFactory::getDbo(); 
            $query= $db->getQuery(true); 

            //Hole alle Daten 
            $query->select('t2.id, t2.date, t2.goalsteam1, t2.goalsteam2, t1a.team AS mannschaft1, t1b.team AS mannschaft2'); 
            $query->from('#__tournament AS t2'); 
            $query->join('left','#__team AS t1a ON t2.team1 = t1a.id'); 
            $query->join('left','#__team AS t1b ON t2.team2 = t1b.id'); 
            $query->order('date'); 

            //und liefere es zurück 
            return $query;         
        } 

    }  

The View

class TippspielViewTippview extends JViewLegacy 
    { 
        //Variable zur Speicherung aller Teams 
        protected $pages; 
        protected $games; 

        function display($tpl = null) 
        { 
            //Hole Daten aus dem Modul 
            $this->games = $this->get('Items'); 
            $this->pages = $this->get('Pagination'); 

            //Layout aktivieren und ausgeben 
            parent::display($tpl); 
        } 
    }  

The Form

<form action="<?php echo JRoute::_('index.php?option=com_tippspiel&view=tippview'); ?>" method= "post" name="adminForm" id="adminForm">
    <?php echo $this->pages->getLimitBox(); ?>
    <table class="table table-striped">
        <thead>
            <tr>
                <th>Heim</th>
                <th>Gast</th>
                <th>Spielbeginn</th>
                <th>Tipp</th>
                <th>Ergebnis</th>
                <th>Punkte</th>
            </tr>
        </thead>
        <tbody>
             <?php foreach($this->games as $i => $game): ?>
                <tr>
                    <td><?php echo $game->mannschaft1; ?></td>
                    <td><?php echo $game->mannschaft2; ?></td>
                    <td><?php echo JHtml::date($game->date); ?></td>
                    <td>Tipp</td>
                    <td><?php echo $game->goalsteam1; ?> : <?php echo $game->goalsteam2; ?></td>
                    <td>Punkte</td>
                </tr>
             <?php endforeach; ?>
        </tbody>
هل كانت مفيدة؟

المحلول

JModelList is for listing items.

To display create/edit form and save item, you need to use JModelAdmin.

However what you are trying to save is not "an item", so you could use JModelLegacy. Using JModelList here is not really a big issue, it still works but I prefer JModelLegacy.

You post your values to a controller, the controller get the values and save, after saving it redirects you to another view or the same view.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top