<div class="form-col-2 form-text balance-width">
<?php
$paymentmethod=array();
$allmethod=array('cash','repurchase', 'earning', 'commission', 'processor', 'ca:re', 'ca:ea', 'ca:co', 're:ea', 're:co', 'ea:co', 'ca:re:ea', 're:ea:co', 'ea:co:ca', 'co:ca:re', 'ca:ea:re:co');
$methodarray=@explode(",",$revenueplans['Revenueplan']['paymentmethod']);
$find=array('ca', 'ea', 're', 'co', ':');
$replace=array('Cash Balance', 'Earning Balance', 'Re-purchase Balance', 'Commission Balance', ' + ');
foreach($methodarray as $methodnm)
{
if(in_array($methodnm,$allmethod))
{
if(!in_array($methodnm,array('cash','repurchase', 'earning', 'commission', 'processor')))
$methodnmdisp=str_replace($find, $replace, $methodnm);
elseif($methodnm=='processor')
$methodnmdisp=ucfirst($methodnm);
elseif($methodnm=='repurchase')
$methodnmdisp="Re-purchase Balance";
else
$methodnmdisp=ucfirst($methodnm)." Balance";
$paymentmethod[$methodnm]=__($methodnmdisp);
}
}
//$paymentmethod=array();
//if(strpos($revenueplans['Revenueplan']['paymentmethod'],'cash') !== false)
// $paymentmethod['cash']=__('Cash Balance');
//if(strpos($revenueplans['Revenueplan']['paymentmethod'],'repurchase') !== false)
// $paymentmethod['repurchase']=__('Re-purchase Balance');
//if(strpos($revenueplans['Revenueplan']['paymentmethod'],'earning') !== false)
// $paymentmethod['earning']=__('Earning Balance');
//if(strpos($revenueplans['Revenueplan']['paymentmethod'],'commission') !== false)
// $paymentmethod['commission']=__('Commission Balance');
//if(strpos($revenueplans['Revenueplan']['paymentmethod'],'processor') !== false)
// $paymentmethod['processor']=__('Payment Processor');
if($SITECONFIG['balance_type']==1)
{
echo $this->Form->radio('paymentmethod', $paymentmethod, array('value'=>'cash', 'legend' => false, 'separator'=>' ', 'onchange'=>'if(this.value=="processor") {$(".paymentprocessorfield").show(500);} else{$(".paymentprocessorfield").hide(500);} if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"'.$SITEURL.'app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}'));
}
elseif($SITECONFIG['balance_type']==2)
{
echo $this->Form->radio('paymentmethod', $paymentmethod, array('value'=>'cash', 'legend' => false, 'separator'=>' ', 'onchange'=>'if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"'.$SITEURL.'app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}'));
}
?>
<div class="height7"></div>
</div>
和代码的结果(我通过Chrome中的Inspect Element得到代码结果)
<div class="form-col-2 form-text balance-width">
<input type="radio" name="data[Revenueplan][paymentmethod]" id="RevenueplanPaymentmethodCash" value="cash" checked="checked" onchange="if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"https://godincome.com/app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}" required="required">
<label for="RevenueplanPaymentmethodCash">Cash Balance</label>
<input type="radio" name="data[Revenueplan][paymentmethod]" id="RevenueplanPaymentmethodRepurchase" value="repurchase" onchange="if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"https://godincome.com/app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}" required="required">
<label for="RevenueplanPaymentmethodRepurchase">Re-purchase Balance</label>
<input type="radio" name="data[Revenueplan][paymentmethod]" id="RevenueplanPaymentmethodProcessor" value="processor" onchange="if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"https://godincome.com/app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}" required="required">
<label for="RevenueplanPaymentmethodProcessor">Processor</label>
<input type="radio" name="data[Revenueplan][paymentmethod]" id="RevenueplanPaymentmethodCaRe" value="ca:re" onchange="if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"https://godincome.com/app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}" required="required">
<label for="RevenueplanPaymentmethodCaRe">Cash Balance + Re-purchase Balance</label>
<div class="height7"></div>
</div>
所以我的请求是如何为每个输入和标签添加名为“PayProcessorBox”的div和类,如此结果
(我想在一个div中输入和标签)
<div class="form-col-2 form-text balance-width">
<div class="PayProcessorBox">
<input type="radio" name="data[Revenueplan][paymentmethod]" id="RevenueplanPaymentmethodCash" value="cash" checked="checked" onchange="if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"https://godincome.com/app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}" required="required">
<label for="RevenueplanPaymentmethodCash">Cash Balance</label>
</div>
<div class="PayProcessorBox">
<input type="radio" name="data[Revenueplan][paymentmethod]" id="RevenueplanPaymentmethodRepurchase" value="repurchase" onchange="if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"https://godincome.com/app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}" required="required">
<label for="RevenueplanPaymentmethodRepurchase">Re-purchase Balance</label>
</div>
<div class="PayProcessorBox">
<input type="radio" name="data[Revenueplan][paymentmethod]" id="RevenueplanPaymentmethodProcessor" value="processor" onchange="if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"https://godincome.com/app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}" required="required">
<label for="RevenueplanPaymentmethodProcessor">Processor</label>
</div>
<div class="PayProcessorBox">
<input type="radio" name="data[Revenueplan][paymentmethod]" id="RevenueplanPaymentmethodCaRe" value="ca:re" onchange="if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"https://godincome.com/app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}" required="required">
<label for="RevenueplanPaymentmethodCaRe">Cash Balance + Re-purchase Balance</label>
</div>
<div class="height7"></div>
</div>
谢谢。
答案 0 :(得分:2)
很确定你只需回复几行这样的话:
echo "<div class=\"PayProcessorBox\">"; // add this line
if($SITECONFIG['balance_type']==1)
{
echo $this->Form->radio('paymentmethod', $paymentmethod, array('value'=>'cash', 'legend' => false, 'separator'=>' ', 'onchange'=>'if(this.value=="processor") {$(".paymentprocessorfield").show(500);} else{$(".paymentprocessorfield").hide(500);} if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"'.$SITEURL.'app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}'));
}
elseif($SITECONFIG['balance_type']==2)
{
echo $this->Form->radio('paymentmethod', $paymentmethod, array('value'=>'cash', 'legend' => false, 'separator'=>' ', 'onchange'=>'if(this.value=="processor"){processorextrafield($("#paymentprocessors").val(),processer,"'.$SITEURL.'app/processorextrafield","Revenueplan",".extrafield");showprocfee(1);}else{$(".extrafield").html("");showprocfee(0);}if(this.value.indexOf("re:")>=0 || this.value.indexOf(":re")>=0) {$(".refirstfield").show(500);} else{$(".refirstfield").hide(500);}'));
}
echo "</div>"; // add this line
答案 1 :(得分:0)
那么,你需要将它添加到循环的开始和结束处,它实际上是回显的:
?> <div class="PayProcessorBox"> <?php
// ... php display code displaying each input and label
?> </div> <?php
离开php coe有点欺骗,但它100%有效。
答案 2 :(得分:0)
使用潜入循环
foreach($methodarray as $methodnm)
{
?>div class="PayProcessorBox"> <?php
if(in_array($methodnm,$allmethod))
{
if(!in_array($methodnm,array('cash','repurchase', 'earning', 'commission', 'processor')))
$methodnmdisp=str_replace($find, $replace, $methodnm);
elseif($methodnm=='processor')
$methodnmdisp=ucfirst($methodnm);
elseif($methodnm=='repurchase')
$methodnmdisp="Re-purchase Balance";
else
$methodnmdisp=ucfirst($methodnm)." Balance";
$paymentmethod[$methodnm]=__($methodnmdisp);
}
?></div><?php
}