I am trying to add a text label inside a return function on Yii2. Here is my code:
return function() {
return [
'main' => [
[
'alias' => 'siteName',
'type' => 'text',
'label' => Yii::t('sk', 'Site name'),
'rules' => [
['string', 'min' => 2, 'max' => 255],
]
],
[
'alias' => 'siteAddress',
'type' => 'text',
'label' => Yii::t('sk', 'Company contact address'),
'rules' => [
['string', 'min' => 0, 'max' => 2048],
['default', 'value' => ''],
]
],
[
'alias' => 'sitePhone',
'type' => 'text',
'label' => Yii::t('sk', 'Company contact phone'),
'rules' => [
['string', 'min' => 0, 'max' => 2048],
['default', 'value' => ''],
]
],
];
};
and here is the HTML output:
Site Name
Company contact address
Company contact phone
How can add a new title after "Site name" so i can get this ?
Site Name
-- CONTACT SETTINGS--
Company contact address
Company contact phone
I already tried something like that:
return function() {
return [
'main' => [
[
'alias' => 'siteName',
'type' => 'text',
'label' => Yii::t('sk', 'Site name'),
'rules' => [
['string', 'min' => 2, 'max' => 255],
]
],
[
'label' => Yii::t('sk', '-- CONTACT SETTINGS --'),
'alias' => 'siteAddress',
'type' => 'text',
'label' => Yii::t('sk', 'Company contact address'),
'rules' => [
['string', 'min' => 0, 'max' => 2048],
['default', 'value' => ''],
]
],
[
'alias' => 'sitePhone',
'type' => 'text',
'label' => Yii::t('sk', 'Company contact phone'),
'rules' => [
['string', 'min' => 0, 'max' => 2048],
['default', 'value' => ''],
]
],
];
};
but didn't work at all.
try adding the new entry betwwen siteName and siteAddress ..
return function() {
return [
'main' => [
[
'alias' => 'siteName',
'type' => 'text',
'label' => Yii::t('sk', 'Site name'),
'rules' => [
['string', 'min' => 2, 'max' => 255],
]
],
[
'label' => Yii::t('sk', '-- CONTACT SETTINGS --'),
'alias' => 'siteAddress',
'type' => 'text',
'rules' => [
['string', 'min' => 0, 'max' => 2048],
['default', 'value' => ''],
]
],
[
'alias' => 'siteAddress',
'type' => 'text',
'label' => Yii::t('sk', 'Company contact address'),
'rules' => [
['string', 'min' => 0, 'max' => 2048],
['default', 'value' => ''],
]
],
[
'alias' => 'sitePhone',
'type' => 'text',
'label' => Yii::t('sk', 'Company contact phone'),
'rules' => [
['string', 'min' => 0, 'max' => 2048],
['default', 'value' => ''],
]
],
];
};
But '-- CONTACT SETTINGS --' seems just an header to me and not a field so you should check for you code how manange header.