Comments (13)
i'll check the example documentation but here is screen from my test app: http://prntscr.com/7wi131
As you can see validation works fine. Please provide your code, so I checked it
Or you mean that message is not appeared?
As workaround you can use errorSummary
from yii2-multiple-input.
Eugene, thank you for answer. Here is my code.
Model:
namespace frontend\widgets\menu;
use Yii;
use yii\validators\RequiredValidator;
class Configuration extends \common\models\WidgetsConfig
{
public $items;
//public $title;
public function rules()
{
return [
['items', 'validateItems'],
];
}
public function init()
{
parent::init();
}
public function attributeLabels()
{
return [
'items' => 'Пункты меню',
];
}
public function validateItems($attribute)
{
$requiredValidator = new RequiredValidator();
$requiredValidator->message = 'Необходимо заполнить поле.';
foreach($this->$attribute as $index => $row) {
$error = null;
$requiredValidator->validate($row['label'], $error);
if (!empty($error)) {
$key = $attribute . '[' . $index . '][label]';
$this->addError($key, $error);
}
}
}
public function rolesList()
{
return Yii::$app->authManager->getRoles();
}
}
form:
use unclead\widgets\MultipleInput;
use yii\helpers\ArrayHelper;
$roles = Yii::$app->authManager->getRoles();
echo $form->field($model, 'items')->widget(MultipleInput::className(), [
'columns' => [
[
'name' => 'label',
'title' => 'Название',
],
[
'name' => 'url',
'title' => 'Ссылка',
'defaultValue' => '/',
],
[
'name' => 'access',
'type' => 'checkboxList',
'title' => 'Доступ',
'items' => ArrayHelper::map($roles, 'name', 'description'),
'options' => [
'item' => function ($index, $label, $name, $checked, $value) {
$render = '<div class="checkbox">
<label>
<input type="checkbox"'.($checked?' checked':'').' name="'.$name.'" value="'.$value.'">
'.$label.'
</label>
</div>';
return $render;
}
],
]
]
])->hint('Если ни одна роль не отмечена, то пункт меню смогут увидеть все пользователи');
May be it not works because the model extends base\Model, not ActiveRecord?
from yii2-multiple-input.
it not works because widget uses Html helper for rendering the inputs.
I'll try to use your solution with some modification for fixing this bug
from yii2-multiple-input.
@mikbox74 Try to update to latest revision. I adapted your code. Let me know if all is correct
from yii2-multiple-input.
I try it with example above. Div.help-block.help-block-error appears but it is empty and field not highlighted. Obviously you forget to put errors from model into the div and add class has-error to div.form-control.
from yii2-multiple-input.
You use form without Ajax validation. Am I right? I forgot about this use case
Отправлено со смартфона Sony Xperia™
Пользователь Michail [email protected] писал:
I try it with example above. Div.help-block.help-block-error appears but it is empty and field not highlighted. Obviously you forget to put errors from model into the div and add class has-error to div.form-control.
Reply to this email directly or view it on GitHub:
#17 (comment)
from yii2-multiple-input.
Yes, right.
2015-07-25 16:23 GMT+04:00, Eugene Tupikov [email protected]:
You use form without Ajax validation. Am I right? I forgot about this use
caseОтправлено со смартфона Sony Xperia™
Пользователь Michail [email protected] писал:
I try it with example above. Div.help-block.help-block-error appears but it
is empty and field not highlighted. Obviously you forget to put errors
from model into the div and add class has-error to div.form-control.
Reply to this email directly or view it on GitHub:
#17 (comment)
Reply to this email directly or view it on GitHub:
#17 (comment)
С уважением, Михаил
from yii2-multiple-input.
Fixed via 8ac7f9b
Please check it again and let me know if the issue reproduced
@mikbox74 please check it again. You can get more detail in multiple columns example
from yii2-multiple-input.
All works fine. Thank you for this incredible widget!
from yii2-multiple-input.
Sorry for reopen issue, close if you think it is better to create new one.
First of all, thanks a lot for such as incredible widget, it fits my need perfectly.
I notice errors works fine but error messages are not show. Is it that for missconfiguration of mine or is it an expected behaviour?
Ressume: Errors are highlighted, but error messages are not shown
from yii2-multiple-input.
@daniroyo create a new issue with the code example to reproduce your case
from yii2-multiple-input.
Sorry, but I finally found the way to show the error, using attribute "enableError" on Column definition like follows.
$form->field($model, 'users')->widget(MultipleInput::class, [
// 'max' => 4,
'addButtonPosition' => [
MultipleInput::POS_FOOTER,
MultipleInput::POS_HEADER,
],
'columns' => [
[
'name' => 'username',
'title' => Yii::t('app', 'Username'),
**'enableError' => true,**
'options' => [
'class' => '',
],
],
]
]);
from yii2-multiple-input.
this option is covered in the documentation 😄
from yii2-multiple-input.
Related Issues (20)
- Cloning doesn't work for nested MultipleInput
- Add manual for each field for custom tabular input? HOT 4
- Embedded does not work correctly HOT 10
- duplicate keys causing strange behavior HOT 2
- Adding new row with DepDrop suddenly not working.
- Is it possible to keep the selected value of a DepDrop when submit returns error? HOT 1
- wrong version hardcoded in composer.json HOT 1
- add button position POS_ROW_BEGIN is shown under the first column HOT 6
- render addons in text fields HOT 2
- Html name attribute HOT 2
- all icon missing HOT 7
- Не работает подсветка ошибок при валидации вновь добавленных полей HOT 1
- The array is converted into an object
- Add button not showing in actionUpdate HOT 1
- Can't handle model update HOT 2
- Yii2 advanced template and Bootstrap 5 HOT 1
- Unable to get the file.
- Иногда не обновляется currentIndex после добавления первой строки HOT 3
- Не работает подсветка ошибок если полей более 9 HOT 1
- DateTimePicker HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-multiple-input.