Jquery aui验证程序:使用Liferay中的自动字段选择

Jquery aui验证程序:使用Liferay中的自动字段选择,jquery,liferay,alloy-ui,liferay-aui,autofield,Jquery,Liferay,Alloy Ui,Liferay Aui,Autofield,我想知道如何为aui编写验证器:选择Autofield类别中的字段 这是我的代码结构: for( loop total number of items) { // CREATE aui select, and aui inputs by appending the index } 自动字段的功能没有问题。我可以在查看表单时通过我的项目集合循环创建重复条目,并且使用liferay提供的PLUS图标“创建”表单时也没有问题 我在容器中有aui:select元素,它将根据Autofield功能进行复

我想知道如何为aui编写验证器:选择Autofield类别中的字段

这是我的代码结构:

for( loop total number of items)
{
// CREATE aui select, and aui inputs by appending the index
}
自动字段的功能没有问题。我可以在查看表单时通过我的项目集合循环创建重复条目,并且使用liferay提供的PLUS图标“创建”表单时也没有问题

我在容器中有aui:select元素,它将根据Autofield功能进行复制。如何为这个aui:select元素提供验证器

假设表单中存在类似以下内容的“模板”:

<aui:select id="elementIdPrefix0" name="elementIdPrefix0" label="Number" showEmptyOption='true' > <!--  options go here  --></aui:select>
理想情况下,您应该能够使用子选择器从
clone
容器中获取节点。我不得不提供一种不同的方法,因为我无法让这种方法发挥作用。我之所以可以使用这种方法,是因为我知道
elementIdPrefix
是什么。为了能够提供一个例子,我继续利用这个事实


对于更动态的方法,可以使用选择器,例如
myNode.one('>selectorString')

我还想包括你在liferay论坛上的问题。字段是表单的一部分吗?是的,字段是表单的一部分谢谢,我将保存此内容以备将来参考。我所做的有点像黑客。我创建了一个与“选择”字段同名的输入字段;-)我已经将其设置为“隐藏”,我正在使用一个自定义验证器函数来检查“选择”字段的值。当然,我会在有时间的时候和你联系的。我将其标记为“已接受”嗨,有没有办法在autofield上应用自定义验证器?
<script>
  AUI().use('liferay-auto-fields', 'aui-form-validator', function(A){

  //Setup rules
  var elementIdPrefix = '<portlet:namespace />elementIdPrefix',
      myRules  = {},  
      rulesRepository = {};

      rulesRepository[elementIdPrefix] = {required:true};
      myRules [elementIdPrefix + '0'] = rulesRepository[elementIdPrefix];

      //Define validator
      var validator = new A.FormValidator({
                             boundingBox: '#<portlet:namespace />myForm',
                             rules: myRules 
                          });

  new Liferay.AutoFields({
    contentBox: '#my-fields',
    fieldIndexes: '<portlet:namespace />indexes',
    on: {
        'clone': function(container){

             //Lookup the clone
             AUI().all('[name^=<portlet:namespace />elementId]').each(function(node, index){

             if(container.row.contains(node)){
                console.log("Assign to " + node.get('id'))
                //inject the rules
                myRules [node.get('id')] = rulesRepository[elementIdPrefix]
             }
            })
        }
   }
 }).render();
});

</script>