Exemple #1
0
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model app\modules\core\models\ContentBlockGroup */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="content-block-group-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'parent_id')->dropDownList(ArrayHelper::map(ContentBlockGroup::find()->all(), 'id', 'name'));
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'sort_order')->textInput();
?>

    <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>
 /**
  * @return string
  */
 public function getNameWithCount()
 {
     return $this->name . ' (' . ContentBlockGroup::find()->where(['group_id' => $this->id])->count() . ')';
 }
Exemple #3
0
 /**
  * @return ContentBlockGroup[]
  */
 public function getGroup()
 {
     return $this->hasOne(ContentBlockGroup::className(), ['id' => 'group_id']);
 }
 /**
  * Finds the ContentBlockGroup model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ContentBlockGroup the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ContentBlockGroup::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }