I
I
i805862018-10-15 12:49:34
Yii
i80586, 2018-10-15 12:49:34

How to use form with namespace in Yii 1?

For example, there is this form:

namespace application\modules\posts\models;

class PostSearch extends \CFormModel
{
}

In this case, when the form is submitted, not only the name of the form (in this case, PostSearch) gets into the GET parameters, but also the entire path with the namespace (&r=application_modules_posts_models_PostSearch[id]=).
How to make sure that only PostSearch gets into GET parameters?
I can get into the jungle of the framework and create a new inherited class with redone logic, but there may already be a stock solution in the framework itself.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vyachin, 2018-10-18
@i80586


class WebApplication extends \CWebApplication
{
public function init()
{
parent::init();
\CHtml::setModelNameConverter(
function ($model) {
$reflection = new \ReflectionClass($model);
return $reflection->getShortName();
}
);
}
}
in index.php
....
Yii::createApplication('WebApplication', $config)->run();

M
Maxim Timofeev, 2018-10-15
@webinar

By means of framework in any way. But in yii2 this issue is resolved, why are you using junk?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question