내 응용 프로그램에서 사용자는 products.here를 추가하기 위해 자신의 필드 목록을 만들 수 있습니다 내 양식입니다.codigniter 유효성 검사에서 복제 된 필드의 유효성을 검사하는 방법은 무엇입니까?
<div class="row productsdiv">
<input type="text" name="product[]" class="product form-control" <?php echo set_value('product[]'); ?>'>
<?php echo form_error('product[]'); ?>
<input type="hidden" name="product_id[]" <?php set_value("");?>>
<input type="text" name="price[]" class="price form-control"<?php echo set_value("price[]");?> placeholder='<?php echo lang('placeholder_price'); ?>'>
<?php echo form_error('price[]'); ?>
<input type="text" name="qty[]" class="quantity form-control"<?php echo set_value("qty[]");?>'>
<?php echo form_error('qty[]'); ?>
</span><span class="total">0</span>
<textarea name="description[]" cols="40" rows="3" class="footerinput form-control"></textarea>
<?php echo form_error('description[]'); ?>
</div><!--Product row end -->
위 div 제품은 버튼을 더 사용하여 복제됩니다. 내 JQuery와
$('#addmore').on('click', function() {
var cloneRow = $('.productsdiv:first').clone();
cloneRow.find("input").val("").end();
cloneRow.find(".total").text("").end();
cloneRow.find(".total").after('<button type="button" class="close lebel-danger" data-dismiss="alert">×</button>');
cloneRow.find(".footerinput").css({"display":"none"});
cloneRow.appendTo('#products');
내 컨트롤러 :
if($_POST){
$this->form_validation->set_rules('customer_id', $this->lang->line('validation_name_label'), 'required');
$this->form_validation->set_rules('date',$this->lang->line('validation_date_label'), 'required');
$this->form_validation->set_rules('product[]', $this->lang->line('validation_product_label'), 'required');
$this->form_validation->set_rules('price[]',$this->lang->line('validation_price_label'), 'required|is_numeric');
$this->form_validation->set_rules('qty[]',$this->lang->line('validation_quantity_label'), 'required|is_numeric');
//remaing logic here after.....
내 문제는 검증이 실패했을 경우, 나는이 때 새로 추가 된 양식 필드 페이지를 다시로드를 잃을 것입니다. 양식 오류를 존중받는 각 양식 필드로 되돌려 보내고 양식 유효성 검사가 실패 할 때 모든 작업을 계속 수행하려면 어떻게해야합니까? 내가 분명하지 않은 경우 미안합니다. 필요한 경우 추가 정보를위한 설명을 작성하십시오.
를 보라? –
아니, 최대한 많이 추가 할 수 있습니다. 또는 좋지 않은 경우 다른 방법을 제안하십시오. 재생을위한 감사합니다 –
어떤 종류의 유효성 검사가 필요합니까? 특정 필드 아래에 오류 메시지를 표시 하시겠습니까? 아니면 폼의 맨 위 또는 맨 아래에 오류를 표시하고 싶습니까? – ss56