Ejemplo n.º 1
0
 public function actionIndex()
 {
     $newsSearch = new NewsSearch();
     $dataProvider = $newsSearch->search(Yii::$app->request->get());
     $statuses = News::getStatuses();
     return $this->render('index', ['newsSearch' => $newsSearch, 'dataProvider' => $dataProvider, 'statuses' => $statuses]);
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [['title', 'string'], ['date_pub', 'date', 'format' => 'yyyy-mm-dd'], ['status', 'integer'], ['status', 'in', 'range' => array_keys(News::getStatuses())]];
 }
Ejemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['title', 'text', 'date_pub'], 'required'], [['title', 'text', 'date_pub', 'preview', 'gallery', 'galleryTitles', 'status'], 'safe'], ['title', 'string', 'max' => 255], ['text', 'string'], ['date_pub', 'date', 'format' => 'php:Y-m-d H:i:s', 'timestampAttribute' => 'date_pub', 'timestampAttributeFormat' => 'php:Y-m-d H:i:s'], ['status', 'integer'], ['status', 'in', 'range' => array_keys(News::getStatuses())]];
 }
Ejemplo n.º 4
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use ijackua\lepture\Markdowneditor;
/* @var $this yii\web\View */
/* @var $model app\models\News */
/* @var $form yii\widgets\ActiveForm */
?>
    <?php 
$form = ActiveForm::begin();
?>
    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 50]);
?>
    <?php 
echo Markdowneditor::widget(['model' => $model, 'attribute' => 'text']);
?>

    <?php 
echo $form->field($model, 'link')->textInput(['maxlength' => 255]);
?>
    <?php 
echo $form->field($model, 'status')->dropDownList(\app\models\News::getStatuses());
?>
    <div class="form-group">
        <?php 
echo Html::submitButton(Yii::t('news', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
    <?php 
ActiveForm::end();