[英]Unable to Validate Field in Shopware Backend Form
I am trying to validate a field in my ExtJs file by sending a hit to my controller.. all works fine and I get the result back.. but the problem is that I am unable to get the me.article
in the code as it shows undefined so my logic in the controller does not return the result as expected. 我正在尝试通过向控制器发送命中来验证ExtJs文件中的字段..一切正常,我得到了结果..但是问题是我无法在代码中获取me.article
显示未定义,因此控制器中的逻辑未按预期返回结果。
Any help would be highly appreciated. 任何帮助将不胜感激。
Note : this only happens for Shopware v.5.4.6. 注意 :仅适用于Shopware v.5.4.6。 It works fine for Shopware 5.2. 它适用于Shopware 5.2。
Shopware.apps.Article.view.detail.Base.prototype.createLeftElements = function() {
var me =this, articleId = null, additionalText = null;
console.log('article', me.article);
if (me.article instanceof Ext.data.Model && me.article.getMainDetail().first() instanceof Ext.data.Model) {
articleId = me.article.getMainDetail().first().get('id');
additionalText = me.article.getMainDetail().first().get('additionalText');
}
me.nameField = Ext.create('Ext.form.field.Text', {
name: 'name',
dataIndex: 'name',
fieldLabel: me.snippets.name,
allowBlank: false,
enableKeyEvents:true,
checkChangeBuffer:700,
labelWidth: 155,
anchor: '100%',
vtype:'remote',
validationUrl: '{url controller="MyController" action="check"}',
validationRequestParam: articleId,
validationErrorMsg: '{s name=detail/base/number_validation}Validation Message.{/s}'
});
// .. some code here which is irrelevant
return [
me.supplierCombo,
me.nameField,
me.mainDetailAdditionalText,
me.numberField,
{
xtype: 'checkbox',
name: 'active',
fieldLabel: me.snippets.active,
inputValue: true,
uncheckedValue:false
},
{
xtype: 'checkbox',
name: 'isConfigurator',
fieldLabel: me.snippets.configurator.fieldLabel,
inputValue: true,
uncheckedValue:false
}
];
};
I am not that deep into ExtJS, but perhaps the CSRF-protection causes this problem? 我对ExtJS的了解不那么深,但是CSRF保护可能会导致此问题吗? Perhaps you need to whitelist your controller. 也许您需要将控制器列入白名单。
https://developers.shopware.com/developers-guide/csrf-protection/#addition-to-backend-token-validation https://developers.shopware.com/developers-guide/csrf-protection/#addition-to-backend-token-validation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.