/** * @inheritdoc */ public function rules() { return [[['curname', 'acronym', 'countryid'], 'required'], ['countryid', 'in', 'range' => array_keys(DatabaseHelper::getCountriesList())], ['curname', 'unique'], [['acronym', 'curname'], 'string', 'max' => 255]]; }
/* @var $this yii\web\View */ /* @var $model common\models\exchange\Exchange */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="exchange-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'exchname')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'countryid')->dropDownList(DatabaseHelper::getCountriesList()); ?> <?php echo $form->field($model, 'web')->textInput(['maxlength' => true]); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?>
use yii\helpers\Html; use yii\grid\GridView; use common\helpers\DatabaseHelper; /* @var $this yii\web\View */ /* @var $searchModel common\models\exchange\ExchangeSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Exchanges'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="exchange-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create Exchange', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'exchname', ['attribute' => 'country.countryname', 'filter' => Html::activeDropDownList($searchModel, 'countryid', DatabaseHelper::getCountriesList(), ['prompt' => 'Select country'])], ['attribute' => 'web', 'format' => 'url'], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
<div class="company-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'companyname')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'web')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'countryid')->dropDownList(DatabaseHelper::getCountriesList(), ['prompt' => 'Select country']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
/** * @inheritdoc */ public function rules() { return [[['exchid'], 'integer'], ['countryid', 'in', 'range' => array_keys(DatabaseHelper::getCountriesList())], [['exchname', 'web'], 'safe']]; }