Advertisement
TheFan1968

Yii - Form-Model

Dec 31st, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: pwend
  5.  * Date: 30.12.2018
  6.  * Time: 14:07
  7.  */
  8.  
  9. namespace app\models;
  10.  
  11. use Yii;
  12. use yii\base\Model;
  13. use yii\helpers\ArrayHelper;
  14. use app\models\Ligen;
  15. use app\models\Saison;
  16.  
  17.  
  18. class LigaSelektorForm extends Model
  19. {
  20.     public $ligaId;
  21.     public $saisonId;
  22.  
  23.     public function rules(){
  24.         return
  25.         [
  26.          [['ligaId','saisonId'], 'required'],
  27.          [['ligaId','saisonId'], 'integer']
  28.         ];
  29.     }
  30.  
  31.     public function attributeLabels()
  32.     {
  33.         return [
  34.             'ligaId' => 'Liga',
  35.             'saisonId' => 'Saison'
  36.         ];
  37.     }
  38.  
  39.     public function getLigaArray(){
  40.         return ArrayHelper::map(Ligen::find()->all(), 'ligaId', 'ligaName');
  41.     }
  42.  
  43.     public function getSaisonArray(){
  44.         return ArrayHelper::map(Saison::find()->all(), 'saisonId', 'saisonName');
  45.     }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement