Example #1
0
 /**
  * @return string
  */
 public function getNameWithCount()
 {
     return $this->name . ' (' . ContentBlockGroup::find()->where(['group_id' => $this->id])->count() . ')';
 }
Example #2
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>
 /**
  * Lists all ContentBlockGroup models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => ContentBlockGroup::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }