示例#1
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="pet-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create Pet'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'petImages', 'value' => function ($data) {
    if ($data->petImages) {
        return "<img src='/" . $data->petImages[0]->source_url . "' />";
    }
    return "<img src='/' />";
}, 'format' => 'raw', 'contentOptions' => ['class' => 'grid-image'], 'filter' => false], 'name', 'date_create', 'date_update', ['attribute' => 'breed_id', 'filter' => \app\models\Breed::getAll(), 'value' => 'brood.breed.name'], ['attribute' => 'brood_id', 'filter' => \app\models\Brood::getAllWithDate(), 'value' => function ($data) {
    return $data->brood->name . " " . $data->brood->date;
}], ['attribute' => 'pet_status_id', 'filter' => \app\models\PetStatus::getAll(), "value" => "petStatus.name"], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
示例#2
0
    <?php 
echo $form->field($model, 'mother_link')->textInput();
?>
    <?php 
echo $form->field($model, 'father_name')->textInput();
?>
    <?php 
echo $form->field($model, 'father_link')->textInput();
?>
    
    <?php 
echo $form->field($model, 'breed_id')->dropDownList(\app\models\Breed::getAll(), ['prompt' => Yii::t('app', '-- select breed --'), 'data-url' => '/pet/subcategory']);
?>

    <?php 
echo $form->field($model, 'brood_id')->dropDownList(\app\models\Brood::getAllWithDate($model->breed_id), ['prompt' => Yii::t('app', '-- select brood --')]);
?>

    <?php 
echo $form->field($model, 'pet_status_id')->dropDownList(\app\models\PetStatus::getAll());
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
示例#3
0
 public function actionSubcategory($id)
 {
     $subcategories = Brood::getAllWithDate($id);
     $response = "<option value=''>" . Yii::t('app', '-- select brood --') . "</option>";
     foreach ($subcategories as $key => $subcategoryName) {
         $response .= "<option value='{$key}'>{$subcategoryName}</option>";
     }
     return $response;
 }