'urlManagerBackend' => [
'class' => 'yii\web\urlManager',
'baseUrl' => 'http://yoursitedomain.ru',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => require(__DIR__ . '../backend/routes.php'),
],
Yii::$app->urlManagerBackend->createUrl(['controller/action', 'parametr1' => 'value1']),
program {var} begin end
Array
(
[0] => {
[1] => var
[2] => }
[3] => begin
[4] => end
)
$codeForParsing = "program {var} begin end";
$codeAsArray = textToArray($textForParsing);
$map = [];
foreach(array_unique($codeAsArray) as $codeItem) {
if (isset($map[$codeItem]))
continue;
foreach($outp as $group => $groupItems) {
if (($finded = array_search($codeItem, $groupItems)) !== false) {
$map[$codeItem] = [$group, $finded];
}
}
}
$result = [];
foreach($codeAsArray as $codeItem) {
$result[] = [$codeItem, $map[$codeItem][0], $map[$codeItem][1]];
}
[
['{', 'ogran', индексЛексемы]
['var', 'oper', индексЛексемы],
['}', 'ogran', индексЛексемы],
....
]
class ControllerForm extends \yii\web\Controller
{
public function actionCreate()
{
$post = Yii::$app->request->post();
$step = Yii::$app->request->post('step', 'step1');
$model = ModelForm::model($step);
$model->attributes = $post;
if ($model->load($post) && $model->validate()) {
if ($step === 'stepLast' && $model->save()) {
return $this->redirect(Url::toRoute(['index']));
}
}
return $this->render('form', ['model' => $model]);
}
}
class ModelForm extends ActiveRecord
{
public function rules()
{
return [
[['field1', 'field2'], 'required', 'on' => 'step1'],
[['field3'], 'required', 'on' => 'step2'],
[['field1', 'field2', 'field3'], 'safe', 'on' => ['step1', 'step2', 'stepLast']]
];
}
}
$form = ActiveForm::begin([
'layout' => 'horizontal',
]);
echo $form->field($model, 'name', ['options' => ['class' => 'name '.$model->scenario]]);
ActiveForm::end();
.name.step1 {
display: block;
}
.name.step2 {
display: none;
}
Пробовал исправить на:
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use frontend\models\Country;
use frontend\models\Country;
use app\models\Country;
public function tableName()
{
return 'country';
}
public static function tableName()
{
return '{{%' . Inflector::camel2id(StringHelper::basename(get_called_class()), '_') . '}}';
}