当前位置: 首页>>代码示例>>PHP>>正文


PHP DateHelper::to_date_select_tag方法代码示例

本文整理汇总了PHP中DateHelper::to_date_select_tag方法的典型用法代码示例。如果您正苦于以下问题:PHP DateHelper::to_date_select_tag方法的具体用法?PHP DateHelper::to_date_select_tag怎么用?PHP DateHelper::to_date_select_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateHelper的用法示例。


在下文中一共展示了DateHelper::to_date_select_tag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testTo_date_select_tag

 /**
  *  Test to_date_select_tag() method
  *
  *  Test {@link DateHelper::to_date_select_tag()} method
  */
 public function testTo_date_select_tag()
 {
     $dh = new DateHelper('Person', 'birthdate');
     $dh->controller_object = new ActionController();
     $ar = new ActiveRecord();
     $dh->controller_object->Person = $ar;
     //  With no value in $_REQUEST, data should be
     //  retrieved from the the ActiveRecord
     $ar->expect_query("birthdate", "1999-02-17");
     //  Test with default format
     $this->assertEquals('<select name="Person[birthdate(1i)]">' . "\n" . '<option value="1994">1994</option>' . "\n" . '<option value="1995">1995</option>' . "\n" . '<option value="1996">1996</option>' . "\n" . '<option value="1997">1997</option>' . "\n" . '<option value="1998">1998</option>' . "\n" . '<option value="1999"  selected="selected">1999</option>' . "\n" . '<option value="2000">2000</option>' . "\n" . '<option value="2001">2001</option>' . "\n" . '<option value="2002">2002</option>' . "\n" . '<option value="2003">2003</option>' . "\n" . '<option value="2004">2004</option>' . "\n" . '</select>' . "\n" . ' <select name="Person[birthdate(2i)]">' . "\n" . '<option value="01">January</option>' . "\n" . '<option value="02" selected="selected">February</option>' . "\n" . '<option value="03">March</option>' . "\n" . '<option value="04">April</option>' . "\n" . '<option value="05">May</option>' . "\n" . '<option value="06">June</option>' . "\n" . '<option value="07">July</option>' . "\n" . '<option value="08">August</option>' . "\n" . '<option value="09">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option>' . "\n" . '</select>' . "\n" . ' <select name="Person[birthdate(3i)]">' . "\n" . '<option value="01">01</option>' . "\n" . '<option value="02">02</option>' . "\n" . '<option value="03">03</option>' . "\n" . '<option value="04">04</option>' . "\n" . '<option value="05">05</option>' . "\n" . '<option value="06">06</option>' . "\n" . '<option value="07">07</option>' . "\n" . '<option value="08">08</option>' . "\n" . '<option value="09">09</option>' . "\n" . '<option value="10">10</option>' . "\n" . '<option value="11">11</option>' . "\n" . '<option value="12">12</option>' . "\n" . '<option value="13">13</option>' . "\n" . '<option value="14">14</option>' . "\n" . '<option value="15">15</option>' . "\n" . '<option value="16">16</option>' . "\n" . '<option value="17"  selected="selected">17</option>' . "\n" . '<option value="18">18</option>' . "\n" . '<option value="19">19</option>' . "\n" . '<option value="20">20</option>' . "\n" . '<option value="21">21</option>' . "\n" . '<option value="22">22</option>' . "\n" . '<option value="23">23</option>' . "\n" . '<option value="24">24</option>' . "\n" . '<option value="25">25</option>' . "\n" . '<option value="26">26</option>' . "\n" . '<option value="27">27</option>' . "\n" . '<option value="28">28</option>' . "\n" . '<option value="29">29</option>' . "\n" . '<option value="30">30</option>' . "\n" . '<option value="31">31</option>' . "\n" . '</select>' . "\n", $dh->to_date_select_tag());
     $_REQUEST['Person']['birthdate(1i)'] = '1955';
     $_REQUEST['Person']['birthdate(2i)'] = '08';
     $_REQUEST['Person']['birthdate(3i)'] = '13';
     //  Test with default format
     $this->assertEquals('<select name="Person[birthdate(1i)]">' . "\n" . '<option value="1950">1950</option>' . "\n" . '<option value="1951">1951</option>' . "\n" . '<option value="1952">1952</option>' . "\n" . '<option value="1953">1953</option>' . "\n" . '<option value="1954">1954</option>' . "\n" . '<option value="1955"  selected="selected">1955</option>' . "\n" . '<option value="1956">1956</option>' . "\n" . '<option value="1957">1957</option>' . "\n" . '<option value="1958">1958</option>' . "\n" . '<option value="1959">1959</option>' . "\n" . '<option value="1960">1960</option>' . "\n" . '</select>' . "\n" . ' <select name="Person[birthdate(2i)]">' . "\n" . '<option value="01">January</option>' . "\n" . '<option value="02">February</option>' . "\n" . '<option value="03">March</option>' . "\n" . '<option value="04">April</option>' . "\n" . '<option value="05">May</option>' . "\n" . '<option value="06">June</option>' . "\n" . '<option value="07">July</option>' . "\n" . '<option value="08" selected="selected">August</option>' . "\n" . '<option value="09">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option>' . "\n" . '</select>' . "\n" . ' <select name="Person[birthdate(3i)]">' . "\n" . '<option value="01">01</option>' . "\n" . '<option value="02">02</option>' . "\n" . '<option value="03">03</option>' . "\n" . '<option value="04">04</option>' . "\n" . '<option value="05">05</option>' . "\n" . '<option value="06">06</option>' . "\n" . '<option value="07">07</option>' . "\n" . '<option value="08">08</option>' . "\n" . '<option value="09">09</option>' . "\n" . '<option value="10">10</option>' . "\n" . '<option value="11">11</option>' . "\n" . '<option value="12">12</option>' . "\n" . '<option value="13"  selected="selected">13</option>' . "\n" . '<option value="14">14</option>' . "\n" . '<option value="15">15</option>' . "\n" . '<option value="16">16</option>' . "\n" . '<option value="17">17</option>' . "\n" . '<option value="18">18</option>' . "\n" . '<option value="19">19</option>' . "\n" . '<option value="20">20</option>' . "\n" . '<option value="21">21</option>' . "\n" . '<option value="22">22</option>' . "\n" . '<option value="23">23</option>' . "\n" . '<option value="24">24</option>' . "\n" . '<option value="25">25</option>' . "\n" . '<option value="26">26</option>' . "\n" . '<option value="27">27</option>' . "\n" . '<option value="28">28</option>' . "\n" . '<option value="29">29</option>' . "\n" . '<option value="30">30</option>' . "\n" . '<option value="31">31</option>' . "\n" . '</select>' . "\n", $dh->to_date_select_tag());
     //  Test 'month_before_year' option
     $this->assertEquals('<select name="Person[birthdate(2i)]">' . "\n" . '<option value="01">January</option>' . "\n" . '<option value="02">February</option>' . "\n" . '<option value="03">March</option>' . "\n" . '<option value="04">April</option>' . "\n" . '<option value="05">May</option>' . "\n" . '<option value="06">June</option>' . "\n" . '<option value="07">July</option>' . "\n" . '<option value="08" selected="selected">August</option>' . "\n" . '<option value="09">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option>' . "\n" . '</select>' . "\n" . ' <select name="Person[birthdate(1i)]">' . "\n" . '<option value="1950">1950</option>' . "\n" . '<option value="1951">1951</option>' . "\n" . '<option value="1952">1952</option>' . "\n" . '<option value="1953">1953</option>' . "\n" . '<option value="1954">1954</option>' . "\n" . '<option value="1955"  selected="selected">1955</option>' . "\n" . '<option value="1956">1956</option>' . "\n" . '<option value="1957">1957</option>' . "\n" . '<option value="1958">1958</option>' . "\n" . '<option value="1959">1959</option>' . "\n" . '<option value="1960">1960</option>' . "\n" . '</select>' . "\n" . ' <select name="Person[birthdate(3i)]">' . "\n" . '<option value="01">01</option>' . "\n" . '<option value="02">02</option>' . "\n" . '<option value="03">03</option>' . "\n" . '<option value="04">04</option>' . "\n" . '<option value="05">05</option>' . "\n" . '<option value="06">06</option>' . "\n" . '<option value="07">07</option>' . "\n" . '<option value="08">08</option>' . "\n" . '<option value="09">09</option>' . "\n" . '<option value="10">10</option>' . "\n" . '<option value="11">11</option>' . "\n" . '<option value="12">12</option>' . "\n" . '<option value="13"  selected="selected">13</option>' . "\n" . '<option value="14">14</option>' . "\n" . '<option value="15">15</option>' . "\n" . '<option value="16">16</option>' . "\n" . '<option value="17">17</option>' . "\n" . '<option value="18">18</option>' . "\n" . '<option value="19">19</option>' . "\n" . '<option value="20">20</option>' . "\n" . '<option value="21">21</option>' . "\n" . '<option value="22">22</option>' . "\n" . '<option value="23">23</option>' . "\n" . '<option value="24">24</option>' . "\n" . '<option value="25">25</option>' . "\n" . '<option value="26">26</option>' . "\n" . '<option value="27">27</option>' . "\n" . '<option value="28">28</option>' . "\n" . '<option value="29">29</option>' . "\n" . '<option value="30">30</option>' . "\n" . '<option value="31">31</option>' . "\n" . '</select>' . "\n", $dh->to_date_select_tag(array('month_before_year' => true)));
     //  Test with 'discard_year' option
     $this->assertEquals('<select name="Person[birthdate(2i)]">' . "\n" . '<option value="01">January</option>' . "\n" . '<option value="02">February</option>' . "\n" . '<option value="03">March</option>' . "\n" . '<option value="04">April</option>' . "\n" . '<option value="05">May</option>' . "\n" . '<option value="06">June</option>' . "\n" . '<option value="07">July</option>' . "\n" . '<option value="08" selected="selected">August</option>' . "\n" . '<option value="09">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option>' . "\n" . '</select>' . "\n" . ' <select name="Person[birthdate(3i)]">' . "\n" . '<option value="01">01</option>' . "\n" . '<option value="02">02</option>' . "\n" . '<option value="03">03</option>' . "\n" . '<option value="04">04</option>' . "\n" . '<option value="05">05</option>' . "\n" . '<option value="06">06</option>' . "\n" . '<option value="07">07</option>' . "\n" . '<option value="08">08</option>' . "\n" . '<option value="09">09</option>' . "\n" . '<option value="10">10</option>' . "\n" . '<option value="11">11</option>' . "\n" . '<option value="12">12</option>' . "\n" . '<option value="13"  selected="selected">13</option>' . "\n" . '<option value="14">14</option>' . "\n" . '<option value="15">15</option>' . "\n" . '<option value="16">16</option>' . "\n" . '<option value="17">17</option>' . "\n" . '<option value="18">18</option>' . "\n" . '<option value="19">19</option>' . "\n" . '<option value="20">20</option>' . "\n" . '<option value="21">21</option>' . "\n" . '<option value="22">22</option>' . "\n" . '<option value="23">23</option>' . "\n" . '<option value="24">24</option>' . "\n" . '<option value="25">25</option>' . "\n" . '<option value="26">26</option>' . "\n" . '<option value="27">27</option>' . "\n" . '<option value="28">28</option>' . "\n" . '<option value="29">29</option>' . "\n" . '<option value="30">30</option>' . "\n" . '<option value="31">31</option>' . "\n" . '</select>' . "\n", $dh->to_date_select_tag(array('discard_year' => true)));
     //  Test 'month_before_year' and 'discard_day' options
     $this->assertEquals('<select name="Person[birthdate(2i)]">' . "\n" . '<option value="01">January</option>' . "\n" . '<option value="02">February</option>' . "\n" . '<option value="03">March</option>' . "\n" . '<option value="04">April</option>' . "\n" . '<option value="05">May</option>' . "\n" . '<option value="06">June</option>' . "\n" . '<option value="07">July</option>' . "\n" . '<option value="08" selected="selected">August</option>' . "\n" . '<option value="09">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option>' . "\n" . '</select>' . "\n" . ' <select name="Person[birthdate(1i)]">' . "\n" . '<option value="1950">1950</option>' . "\n" . '<option value="1951">1951</option>' . "\n" . '<option value="1952">1952</option>' . "\n" . '<option value="1953">1953</option>' . "\n" . '<option value="1954">1954</option>' . "\n" . '<option value="1955"  selected="selected">1955</option>' . "\n" . '<option value="1956">1956</option>' . "\n" . '<option value="1957">1957</option>' . "\n" . '<option value="1958">1958</option>' . "\n" . '<option value="1959">1959</option>' . "\n" . '<option value="1960">1960</option>' . "\n" . '</select>' . "\n", $dh->to_date_select_tag(array('month_before_year' => true, 'discard_day' => true)));
 }
开发者ID:phpontrax,项目名称:trax,代码行数:28,代码来源:DateHelperTest.php

示例2: array

 /**
  *  @todo Document this method
  *
  *  @param string object_name    Name of an ActiveRecord subclass
  *  @param string attribute_name Name of an attribute of $object_name
  *  @param string[] options
  *  @uses attribute_name
  *  @uses column_type()
  *  @uses error_wrapping()
  *  @uses object_name
  *  @uses DateHelper::to_date_select_tag()
  *  @uses FormHelper::to_boolean_select_tag()
  *  @uses FormHelper::to_input_field_tag()
  *  @uses FormHelper::to_text_area_tag()
  *  @uses to_datetime_select_tag()
  *  @uses object()
  */
 function to_tag($object_name, $attribute_name, $options = array())
 {
     $this->object_name = $object_name;
     $this->attribute_name = $attribute_name;
     $form = new FormHelper($object_name, $attribute_name);
     switch ($this->column_type()) {
         case 'string':
         case 'varchar':
         case 'varchar2':
             $field_type = preg_match("/password/i", $this->attribute_name) ? "password" : "text";
             $results = $form->to_input_field_tag($field_type, $options);
             break;
         case 'text':
         case 'blob':
             $results = $form->to_text_area_tag($options);
             break;
         case 'integer':
         case 'int':
         case 'number':
         case 'float':
         case 'real':
             $results = $form->to_input_field_tag("text", $options);
             break;
         case 'date':
             $form = new DateHelper($object_name, $attribute_name);
             $results = $form->to_date_select_tag($options);
             break;
         case 'datetime':
         case 'timestamp':
             $results = $this->to_datetime_select_tag($options);
             break;
         case 'boolean':
         case 'bool':
             $results = $form->to_boolean_select_tag($options);
             break;
     }
     if (count($this->object()->errors)) {
         $results = $this->error_wrapping($results, $this->object()->errors[$this->attribute_name]);
     }
     return $results;
 }
开发者ID:phpontrax,项目名称:trax,代码行数:58,代码来源:active_record_helper.php


注:本文中的DateHelper::to_date_select_tag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。