Exemple #1
0
use yii\helpers\ArrayHelper;
use app\models\ServiceCategories;
use dosamigos\ckeditor\CKEditor;
/* @var $this yii\web\View */
/* @var $model app\models\Services */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="services-form">

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

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

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

    <?php 
echo $form->field($model, 'text')->widget(CKEditor::className(), []);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
 public function actionIndex()
 {
     Yii::$app->session->removeFlash('activeButton');
     $categories = ServiceCategories::find()->with('services')->all();
     return $this->render('index', ['categories' => $categories]);
 }
 /**
  * Lists all ServiceCategories models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => ServiceCategories::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }