Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderHeaderCellContent not uses label from search/Model for GridView #4504

Closed
githubjeka opened this issue Jul 29, 2014 · 3 comments
Closed

Comments

@githubjeka
Copy link
Contributor

<?=
GridView::widget(
    [
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            [
                'attribute' => 'pStatus',
                'format' => 'html',
                'value' => function ($data) {
                        return '<div class="label '
                        . $data->project->statuses[$data->project->status]['label'] . '">'
                        . $data->project->statuses[$data->project->status]['text'] . '</div>';
                    },
                'filter' => $searchModel->getPStatus()
            ],           
        ],
    ]
); ?>
namespace frontend\models\search;

use frontend\models\Object as ObjectModel;
use yii\helpers\ArrayHelper;

class Object extends ObjectModel
{

 public $pStatus;

 public function attributeLabels()
    {
        return ArrayHelper::merge(
            parent::attributeLabels(),
            [
                'project_date' => 'Дата проекта, не моложе',
                'pStatus' => 'Статус проекта',
            ]
        );
    }
}
// on view 
#   P Status //must be 'Статус проекта',

Attribute pStatus uses only in frontend\models\search\Object. Because it's set in frontend\models\Object not irrationally. But renderHeaderCellContent uses only attributeLabels from parent model .

It may be worth it to fix?

@klimov-paul
Copy link
Member

See explanation at #4738

@cebe cebe removed this from the 2.0.1 milestone Aug 26, 2014
@arogachev
Copy link
Contributor

Was facing this issue too, I think this should be added to the core.

@githubjeka
Copy link
Contributor Author

Again stepped on these rakes :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants