English 中文(简体)
表格——《刑法》中的退学
原标题:form_dropdown in CodeIgniter

I m从形式_dropdown——基本上,在我经过验证后重新上下页时,这些数值被rew升。

这比数导致3个日、月和年下降:

$days = array(0 =>  Day... );
        for ($i = 1; $i <= 31; $i++)
        {
            $days[] = $i;
        }
        $months = array(0 =>  Month... , );
        for ($i = 1; $i <= 12; $i++)
        {
            $months[] = $i;
        }
        $years = array(0 =>  Year... );
        for ($i = 2010; $i <= 2012; $i++)
        {
            $years[$i] = $i; 
            echo "<pre>"; print_r($years); echo "</pre>";//remove this
        }

        $selected_day = (isset($selected_day)) ? $selected_day : 0;
        $selected_month = (isset($selected_month)) ? $selected_month : 0;
        $selected_year = (isset($selected_year)) ? $selected_year : 0;
        echo "<p>";
            echo form_label( Select date: ,  day , array( class  =>  left ));
            echo form_dropdown( day , $days, $selected_day,  class="combosmall" ); 
            echo form_dropdown( month , $months, $selected_month,  class="combosmall" ); 
            echo form_dropdown( year , $years, $selected_year,  class="combosmall" ); 
        echo "</p>";

......并促成:

    <p><label for="day" class="left">Select date:</label><select name="day" class="combosmall"> 
<option value="0" selected="selected">Day...</option> 
<option value="1">1</option> 
<option value="2">2</option> 
<option value="3">3</option> 
<option value="4">4</option> 
<option value="5">5</option> 
<option value="6">6</option> 
<option value="7">7</option> 
<option value="8">8</option> 
<option value="9">9</option> 
<option value="10">10</option> 
<option value="11">11</option> 
<option value="12">12</option> 
<option value="13">13</option> 
<option value="14">14</option> 
<option value="15">15</option> 
<option value="16">16</option> 
<option value="17">17</option> 
<option value="18">18</option> 
<option value="19">19</option> 
<option value="20">20</option> 
<option value="21">21</option> 
<option value="22">22</option> 
<option value="23">23</option> 
<option value="24">24</option> 
<option value="25">25</option> 
<option value="26">26</option> 
<option value="27">27</option> 
<option value="28">28</option> 
<option value="29">29</option> 
<option value="30">30</option> 
<option value="31">31</option> 
</select><select name="month" class="combosmall"> 
<option value="0" selected="selected">Month...</option> 
<option value="1">1</option> 
<option value="2">2</option> 
<option value="3">3</option> 
<option value="4">4</option> 
<option value="5">5</option> 
<option value="6">6</option> 
<option value="7">7</option> 
<option value="8">8</option> 
<option value="9">9</option> 
<option value="10">10</option> 
<option value="11">11</option> 
<option value="12">12</option> 
</select><select name="year" class="combosmall"> 
<option value="0" selected="selected">Year...</option> 
<option value="2010">2010</option> 
<option value="2011">2011</option> 
<option value="2012">2012</option> 
</select></p>

然而,当表格在验证后重新载荷时,上述相同的代码会产生以下结果:

<!-- days and months... -->
<select name="year" class="combosmall"> 
<option value="0" selected="selected">Year...</option> 
<option value="1">2010</option> 
<option value="2">2011</option> 
<option value="3">2012</option> 
</select>

因此,基本价值从2010年的1起开始。 几天和几个月的情况也是如此,但显然,这并没有改变这一具体情况,因为价值观从一线开始。

我如何确定这一点——为什么发生?

编辑:审定规则是:

$this->load->library( form_validation );
//...rules for other fields..
$this->form_validation->set_rules( day ,  day ,  required|xss_clean );
$this->form_validation->set_rules( month ,  month ,  required|xss_clean );
$this->form_validation->set_rules( year ,  year ,  required|xss_clean );        
$this->form_validation->set_error_delimiters( <p class="error"> ,  </p> );
//define other errors
if($this->input->post( day ) == 0 || $this->input->post( month ) == 0 || $this->input->post( year ) == 0) 
    {
        $data[ error ] = "Please check the date of your event.";
    }
问题回答

不能确定这种情况发生的原因。 一切都看着ok(尽管你可能不需要,而且你的用户界定检查!) 或许可以尝试使用不同的变量作为你的对口单位,时间、周和年。 页: 1

$days = array(0 =>  Day... );
    for ($d = 1; $d <= 31; $d++)
    {
        $days[] = $d;
    }
    $months = array(0 =>  Month... , );
    for ($m = 1; $m <= 12; $m++)
    {
        $months[] = $m;
    }
    $years = array(0 =>  Year... );
    for ($y = 2010; $y <= 2012; $y++)
    {
        $years[$y] = $y; 
    }

我不敢肯定,这是否会奏效,或者为什么会比你的工作好,但也许值得尝试?

如果它不工作,就把每一阵列通过var(var)然后送至 form(dr)法,看它是否与制造阵列相差,或者在助手职能中是否有点 f。 当然,在纯粹的工作场所而不是使用助手来加以规范的工作并不多得多。





相关问题
PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

What s the proper MVC way to do this....?

Quick question about general MVC design principle in PHP, using CodeIgniter or Kohana (I m actually using Kohana). I m new to MVC and don t want to get this wrong... so I m wondering if i have ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

CodeIgniter adding semicolons

How do I stop CodeIgniter adding semicolons ; to data sent via POST that contains ampersand &? For example it is converting "a=1&b=2&c=3" into "a=1&b;=2&c;=3". From looking on the forums ...

Best way to make Admin pages in CodeIgniter?

I m working on an app in CodeIgniter, and I want to have admin pages for several of the objects in the application, and I m wondering what would be the better way to put these into an MVC structure. ...

CodeIgniter form verification and class

I m using the form validation library and have something like this in the view <p> <label for="NAME">Name <span class="required">*</span></label> <?...

热门标签