我有两个表单拥有相同的模型属性,因为 Yii2 生成的字段 id 为ModelName-fieldName所以生成的字段如下:
<select name="Channel[channel]" class="form-control" id="channel-description">
Run Code Online (Sandbox Code Playgroud)
我曾尝试使用fieldConfig中的ActiveForm,但它不ID添加到域本身。
我正在使用服务工作者进行推送通知.我正在使用XHR(Ajax)方法来获取我的通知,这是service-worker.js的代码片段:
var API_ENDPOINT = new Request('/getNotification', {
redirect: 'follow'});
event.waitUntil(
fetch(API_ENDPOINT, {credentials: 'include' })
.then(function(response) {
console.log(response);
if (response.status && response.status != 200) {
// Throw an error so the promise is rejected and catch() is executed
throw new Error('Invalid status code from API: ' +
response.status);
}
// Examine the text in the response
return response.json();
})
.then(function(data) {
console.log('API data: ', data);
var title = 'TEST';
var message = data['notifications'][0].text;
var icon = data['notifications'][0].img;
// Add this to …Run Code Online (Sandbox Code Playgroud)