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

remove attribute labels #2118

Merged
merged 3 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
In order to read more about upgrading and BC breaks have a look at the [UPGRADE Document](UPGRADE.md).

## 2.0.3

+ [#2118](https://github.com/luyadev/luya/pull/2118) Removed conflicting `$attributeLabels` property from DynamicModel (Yii provides this option since 2.0.35, therefore not required by LUYA anymore).

## 2.0.2 (7. December 2021)

+ [#2113](https://github.com/luyadev/luya/pull/2113) Improve error handling for expected composition values configuration.
Expand Down
33 changes: 19 additions & 14 deletions core/base/DynamicModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
*
* ```php
* $model = new DynamicModel(['query']);
* $model->attributeLabels = ['query' => 'Search term'];
* $model->attributeHints = ['query' => 'Enter a search term in order to find articles.'];
* $model->setAttributeHints(['query' => 'Enter a search term in order to find articles.']);
* $model->addRule(['query'], 'string');
* $model->addRule(['query'], 'required');
* ```
Expand All @@ -26,24 +25,30 @@ class DynamicModel extends \yii\base\DynamicModel
* @var array An array with key value pairing where key is the attribute and value the label.
* @since 1.0.15
*/
public $attributeHints = [];
public $_attributeHints = [];

/**
* @var array Assignable attributes by array where key is the label key value the label for the key.
* Sets the attribute hints in a massive way.
*
* @param array $hints Array of attribute hints
* @return $this
* @since 2.0.3
*/
public $attributeLabels = [];

public function setAttributeHints(array $hints)
{
$this->_attributeHints = $hints;
return $this;
}

/**
* {@inheritDoc}
* Get all hints for backwards compatibility.
*
* @return array
* @since 2.0.3
*/
public function attributeLabels()
public function getAttributeHints()
{
$labels = [];
foreach ($this->attributeLabels as $key => $value) {
$labels[$key] = Yii::t('app', $value);
}

return $labels;
return $this->_attributeHints;
}

/**
Expand Down