如何解决在Crud控制器中通过TextField将变量传递给实体方法-Symfony 4.4上的EasyAdmin 3.1
我正在尝试通过文本字段传递变量
/* Find all predessesor cells of input range
*/
function findPredecessor(rng){
var formualaText = rng.getFormula();
/* addMatchesRegex
* supports all A1Notation addresses
* the 2nd regex after the | operator will match all column addresses (A:A,Sheet2!b:B,etc)
* some NamedRanges with names like NameRange1
* Does not support - NamedRange with names including dot,not ending with digits
*/
var addMatchesRegex = /(([\w .'!]+)?(\$?[A-Z]+\$?\d+\b)(:(\$?[A-Z]+\$?\d+))?)|([\w .'!]+)?[A-Z]+:[A-Z]+/gi;
var addMatches = formualaText.match(addMatchesRegex);
Logger.log("%s add matched: %s",addMatches.length,addMatches);
/* fullMatchRegex
* modify addMatches to return also strings like
* 1. SUM,IFERROR,etc - internal sheets functions.
* 2. NamedRanges
*
*/
var fullMatchRegex = /(([\w .'!]+)?([\$A-Z.\d]*)(:(\$?[A-Z]+\$?\d*))?)/gi;
// match regex with formula
var fullMatches = formualaText.match(fullMatchRegex);
Logger.log("Full matches list: %s",fullMatches);
var namedRangesAdd = analyzeMatch(addMatches,fullMatches);
Logger.log("%s total predecessors: %s",namedRangesAdd.length,namedRangesAdd);
}
/* This function accepts the two regex matches list
* and returns one unique list of all predecessor addresses
* @param {Array} addMatches - All A1 notation addresses
* plus some of NamedRanges
* @param {Array} fullMatches - All A1 notation addresses,All NamedRanges,* Other irrelevent matches
*/
function analyzeMatch(addMatches,fullMatches){
/*Expected
First parameter - holds all A1Notation addresses as well as NamedRanges that
their name in the form of /[A-Z]+/d+
NamedRange with name including dot(.) or does not contain digits will not
be on the list
Second Parameter - contains all first list matches,as well as all NamedRanges
names and also irrelevant matches to be filtered like function names and empty string
*/
//Full Matched Addresses to be returned
var mAddresses = [];
//Remove duplicate addresses
var uniqueMatches =
addMatches.filter((item,index)=>addMatches.indexOf(item)===index);
//Get all named Ranges in spread sheet
var nr = SpreadsheetApp.getActive().getNamedRanges();
// Loop Named Ranges arr
nr.forEach(function(item){
/* Check if the name of the current Named Range
* is included in matches
* 1. first in addMatches list
* 2. only if not found in the wider list */
var name = item.getName();
//Check if in addmatches array
var i = uniqueMatches.indexOf(name);
//Build A1Notation address of current NamedRange
var rng = item.getRange();
var add = "'" + rng.getSheet().getName() + "'!" + rng.getA1Notation();
if (i > -1){
//Add the address of curr NamedRange to final list
mAddresses.push(add);
//Remove curr NamedRange from list
uniqueMatches.splice(i,1);
}else if (fullMatches.includes(name)){
// Name found - add the address of the
// Named Range to matched Addresses list
mAddresses.push(add);
}
});
//Add all left matched addresses to final list
mAddresses.push(...uniqueMatches);
return mAddresses;
}
'getArea'是实体中方法的名称, “区域类型”是字段标签。
是否可以传递变量? 我正在尝试:
TextField::new('getArea','Area Type');
但是它不起作用。 通过覆盖 configureFields 方法
,此操作在我的原始控制器中TextField::new(['getArea'=>$someVar],'Area Type');
也许您有一些想法。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。