में सरणी मान को सत्यापित करने के लिए कैसे करें मेरे पास मेरे फॉर्म कार्य अनुभव में है जो संगठन नाम, विभाग का नाम, स्थिति और अवधि के रूप में इनपुट के साथ गतिशील रूप से जोड़ा जाता है।कोडनिर्देशक
<tr>
<td><span class="serial_no">1</span></td>
<td><input type="text" name="organization[]" size="50"/></td>
<td><input type="text" name="department[]" size="50"></td>
<td><input type="text" name="positions[]" size="40"></td>
<td><input type="text" name="duration[]"></td>
</tr>
जबकि सीआई में मान्य मैं निम्नलिखित किया:
$organization = $this->input->post('organization');
$department = $this->input->post('department');
$positions = $this->input->post('positions');
$duration = $this->input->post('duration');
//printr($organization);
for($i = 0; $i < count($organization); $i++)
{
$org = $organization[$i];
$dept = $department[$i];
$pos = $positions[$i];
$dura = $duration[$i];
$this->form_validation->set_rules($org, "Organization", "trim|xss_clean|max_length[1]");
$this->form_validation->set_rules($dept, "Department", "trim|xss_clean|max_length[50]");
$this->form_validation->set_rules($pos, "Position", "trim|xss_clean|max_length[40]");
$this->form_validation->set_rules($dura, "Duration", "trim|xss_clean|integer");
}
और के रूप में त्रुटि प्रदर्शित:
<?php
echo form_error("organization[]");
echo form_error("department[]");
echo form_error("positions[]");
echo form_error("duration[]");
?>
अब समस्या यह पूर्णांक के रूप में अवधि की पुष्टि नहीं करता है। यहां तक कि अगर मैं कुछ यादृच्छिक अल्फा वर्ण डालता हूं तो यह त्रुटियों को नहीं दिखाता है।
जब मैं इस प्रकार सत्यापित करें:
$this->form_validation->set_rules('organization[]', "Organization", "trim|xss_clean|max_length[50]");
$this->form_validation->set_rules('department[]', "Department", "trim|xss_clean|max_length[50]");
$this->form_validation->set_rules('positions[]', "Position", "trim|xss_clean|max_length[40]");
$this->form_validation->set_rules('duration[]',"Duration", "trim|xss_clean|numeric");
यह मेरे प्रपत्र सबमिट यह के रूप में अनिवार्य है जो यह नहीं है अवधि लेता है के रूप में नहीं देता।
मैं इसे कैसे हल करूं?
कोई मदद/सुझाव स्वागत है। धन्यवाद।
शायद तुम नहीं करना चाहिए इस प्रकार मेरी त्रुटियों दिखाया गया है? –
@ सैमी मैंने अपना जवाब अपडेट कर लिया है, कृपया लिंक जोड़ा गया है, कृपया। किसी भी प्रतिक्रिया का स्वागत है। –