我在徘徊是否有机会使用场景作为规则,
在我的模型中,我有
public function rules()
{
return array(
array('delivery, firstNameBilling, lastNameBilling, addressBilling, cityBilling, countryBilling,
postBilling, telephoneBilling, mailBilling, firstNameDelivery, lastNameDelivery, addressDelivery,
cityDelivery, countryDelivery, postDelivery, telephoneDelivery, mailDelivery', 'required'),
array('active', 'numerical', 'integerOnly'=>true),
);
}
在我看来,我有这样的事情
<tr>
<td>
<p><?php echo $form->label($model,'telephoneBilling'); ?><span>: </span><span class="required">*</span></p>
</td>
<td>
<?php echo $form->textField($model,'telephoneBilling'); ?>
<?php echo $form->error($model,'telephoneBilling'); ?>
</td>
</tr>
</table>
<p><?php echo $form->checkBox($model,'active', array('class' => 'change')); ?>
Delivery information: Please check the box if your delivery address differs from your billing address and enter the
required delivery address in the fields provided below.</p>
<div id="deliveryFormWrapper" style="display: none">
<table class="cartReviewTable">
<tr>
<td colspan="4">
<span class="blueTitle"><?php echo CHtml::encode(Yii::t('app', 'Delivery Information ')); ?></span>
</td>
</tr>
<tr>
<td>
<p><?php echo $form->label($model,'firstNameDelivery'); ?><span>: </span><span class="required">*</span></p>
</td>
<td>
<?php echo $form->textField($model,'firstNameDelivery'); ?>
<?php echo $form->error($model,'firstNameDelivery'); ?>
</td>
这只是为您提供图片的一部分,因此当我单击复选框时,我会显示此隐藏的 div,并且他对他的字段有一个规则(第一个 div 包含计费字段,而隐藏的包含交付字段。
当我想提交表单并且未选中复选框时,我不能这样做,因为必填字段,所以我在徘徊是否有机会针对这种情况使用场景以及如何使用,我需要一个线索。
谢谢,希望你能理解我的问题。