$('#contact-form').yiiActiveForm('add', {
id: 'address',
name: 'address',
container: '.field-address',
input: '#address',
error: '.help-block',
validate: function (attribute, value, messages, deferred, $form) {
yii.validation.required(value, messages, {message: "Validation Message Here"});
}
});
ncaught TypeError: Cannot read property 'attributes' of undefined
at jQuery.fn.init.add (yii.activeForm.js:242)
at jQuery.fn.init.$.fn.yiiActiveForm (yii.activeForm.js:16)
at HTMLDocument.<anonymous> (create:1459)
at mightThrow (jquery.js:3583)
at process (jquery.js:3651)
$script = <<< JS
$("#combaine-region_id").change(function(){render()});
$("#point").empty();render();
function render (){
var region = $("#combaine-region_id").val();
if (isFinite(region)) {
$.ajax({
url: "/combaine/cities-region-list-ajax?id=" + region,
dataType : "json",
success: function (data, textStatus) {
cities(data);
}
});
$.ajax({
url: "/combaine/point-time?id=" + region,
dataType : "json",
success: function (data, textStatus) {
points(data);
}
});
}
function points(data){
var points = '';
for (var key in data) {
var result = data[key];
for (var key in result) {
points += result[key] + '<div class="form-group field-combaine-name"><input type="text" class="form-control" id="time[' + key + ']" name="Combaine[time][' + key + ']" value="" placeholder="Sunday"></div>';
}
$('*[data-id="'+key+'"]').append(points);
points = '';
}
}
function cities(data){
var result = '';
data.results.forEach(function(item, i, arr) {
result += '<div class="panel panel-default"><div class="panel-heading">' + item.text +'</div>' +
'<div class="panel-body" data-id="' + item.id + '"></div></div>';
});
$("#point").append(result);
}
}
JS;
$this->registerJs($script);
$('#contact-form').yiiActiveForm('add', {
id: 'address',
name: 'address',
container: '.field-address',
input: '#address',
error: '.help-block',
validate: function (attribute, value, messages, deferred, $form) {
yii.validation.required(value, messages, {message: "Validation Message Here"});
}
});
но почему то не работает