Esempio n. 1
0
use yii\web\JsExpression;
use yii\web\View;
/* @var $this yii\web\View */
/* @var $model common\modules\news\models\News */
/* @var $modelCategory common\modules\news\models\NewsCategory */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="news-form">

    <?php 
$form = ActiveForm::begin(['id' => 'news-form', 'layout' => 'horizontal', 'fieldClass' => RadiataField::className(), 'options' => ['enctype' => 'multipart/form-data']]);
?>

    <?php 
echo FieldHelper::showErrors($model);
?>

    <div class="nav-tabs-custom">
        <!-- Tabs within a box -->
        <ul class="nav nav-tabs">
            <li class="active"><a href="#main-tab" data-toggle="tab"><?php 
echo Yii::t('b/news', 'Main tab');
?>
</a></li>
            <li><a href="#tags-tab" data-toggle="tab"><?php 
echo Yii::t('b/news', 'Tags tab');
?>
</a></li>
            <li><a href="#image-tab" data-toggle="tab"><?php 
echo Yii::t('b/news', 'Image tab');
Esempio n. 2
0
 /**
  * Add tag modal window
  * @return array
  */
 public function actionAddNewTag()
 {
     if (Yii::$app->request->isAjax) {
         $model = new NewsTag();
         if (Yii::$app->request->isPost) {
             foreach (Yii::$app->request->post('NewsTagTranslation', []) as $language => $data) {
                 foreach ($data as $attribute => $translation) {
                     $model->translate($language)->{$attribute} = $translation;
                 }
             }
         }
         if (Yii::$app->request->isPost) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             if ($model->save()) {
                 return ['newId' => $model->id, 'newName' => $model->name];
             } else {
                 return ['errors' => FieldHelper::showErrors($model)];
             }
         } else {
             return $this->renderAjax('newTagAjax', ['model' => $model]);
         }
     } else {
         throw new BadRequestHttpException();
     }
 }