mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
Update SortOrderField.php (#6046)
Allow custom label or hint. E.g. if an attributeLabels is defined in the model for the `fieldName` attribute, `$form->field($model, 'fieldName')->widget(SortOrderField::class)` should render the label defined in the model and not the default `'Sort Order'`.
This commit is contained in:
parent
81b1876e77
commit
9d88da246a
@ -44,12 +44,16 @@ class SortOrderField extends InputWidget
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->field->label(Yii::t('UiModule.form', 'Sort Order'));
|
||||
$this->field->hint(Yii::t('UiModule.form', 'Values between 0 and 10000, the existing elements usually use steps of 100.'));
|
||||
|
||||
$model = $this->model;
|
||||
$attribute = $this->attribute;
|
||||
|
||||
if (!$model->getAttributeLabel($attribute)) {
|
||||
$this->field->label(Yii::t('UiModule.form', 'Sort Order'));
|
||||
}
|
||||
if (!$model->getAttributeHint($attribute)) {
|
||||
$this->field->hint(Yii::t('UiModule.form', 'Values between 0 and 10000, the existing elements usually use steps of 100.'));
|
||||
}
|
||||
|
||||
if ($this->defaultValue !== null && !is_numeric($model->$attribute)) {
|
||||
$model->$attribute = $this->defaultValue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user