2013-01-16 57 views
0

我需要填写的字段应重新填充正确填写的字段,而不要提交表单并为错误填写的字段提供错误。什么是最好的方式来做到这一点?如何在验证通过之前重新填充字段?

请注意,使用此代码,我正在重新填充字段,因为它们应该在提交表单时正确显示,并且在重新加载页面时它们都会显示。

<div class="dropdown_structure"> 
     <?php 

     if($user['location'] == "empty") 
     { 
     echo country_dropdown('location'); 

     } 
     else 
     { 
     echo country_dropdown('location',$user['location']); 

     } 

     ?> 
    </div> 

另请注意,我已经尝试在输入字段中插入值。

$data = array('name' => 'location', 'value' => $this->input->post('location')); 
echo relation_dropdown('location'); 

在此先感谢

回答

1

嗨,如果您使用的是以下国家下拉帮手,你可以设置值的验证在下列方式

Country dropdown helper

country_dropdown('location',array(),set_value('location')) 

甚至在你的第二个下拉使用set_value('field_name')将起作用。如果验证失败,您的选定值将保留。

相关问题