Validation 在angular JS中使用CakePHP表单验证
我正在使用angular js和cake php构建一个简单的发票模块 项目字段在我的视图中使用ng-repeat进行重复,如下所示Validation 在angular JS中使用CakePHP表单验证,validation,cakephp,angularjs,client-side,Validation,Cakephp,Angularjs,Client Side,我正在使用angular js和cake php构建一个简单的发票模块 项目字段在我的视图中使用ng-repeat进行重复,如下所示 <div ng:controller="ItemsCtrl" ng:app> <div class="row-fluid items" > <hr> <ul class="invoice_items" ng:init="invoice={items:[{serial:'',details:'',qt
<div ng:controller="ItemsCtrl" ng:app>
<div class="row-fluid items" >
<hr>
<ul class="invoice_items" ng:init="invoice={items:[{serial:'',details:'',qty:0,unit:'',rate:0,discount:0,amount:0}],pf:0}">
<li ng:repeat="item in invoice.items">
<div class="clear"></div>
<div id="items_row">
<div class="field span1">
<?php
echo $this->TwitterBootstrap->input("Number", array(
"input" => $this->Form->text("Item.{{\$index}}.serial" , array('class' => 'serial span1' ,'placeholder' => 'S.No' , 'ng-model' => 'item.serial' , 'value' => '{{ $index + 1 }}' , 'readonly' => 'readonly' ))
)); ?>
</div>
问题在于,ng REPLAT指令之外的字段会根据需要进行验证,但由于ng REPLAT指令内的字段会在每次页面加载时进行初始化,因此不会对其应用cakephp验证。
你们看到这方面的工作了吗?可能是我的整个架构方法都错了?我认为您应该改变解决问题的方式 使用CakePHP为前端创建RESTAPI和AngularJS。这将更加容易(如果您希望在将来迁移堆栈,即Dart或NodeJS,则会更好) 您可能想阅读:
希望有帮助。哦,太糟糕了。没有检查问题日期。
public $validate = array(
'id' => array(
'notempty' => array(
'rule' => array('notempty'),
),
),
'serial' => array(
'notempty' => array(
'rule' => array('notempty'),
),
),
'details' => array(
'notempty' => array(
'rule' => array('notempty'),
),
),
'quantity' => array(
'notempty' => array(
'rule' => array('notempty'),
),
'naturalnumber' => array(
'rule' => array('naturalnumber'),
'message' => 'Please enter a valid quantity'
),
),
'rate' => array(
'notempty' => array(
'rule' => array('notempty'),
),
'numeric' => array(
'rule' => array('numeric'),
),
),
'discount' => array(
'numeric' => array(
'rule' => array('numeric'),
),
),
'amount' => array(
'notempty' => array(
'rule' => array('notempty'),
),
'numeric' => array(
'rule' => array('numeric'),
),
),
);