PHP development framework Yii Framework tutorial (36) Zii component-DatePicker example

黄舟
Release: 2023-03-05 09:26:01
Original
1186 people have browsed it

CJuiDatePicker is used for date input. It encapsulates the JUI datepicker plug-in. Its basic usage is as follows:

<!--?php echo $form--->errorSummary($model); ?>
  
 <!--?php
 $this--->widget(&#39;zii.widgets.jui.CJuiDatePicker&#39;, array(
    &#39;name&#39;=>&#39;my_date&#39;,
    &#39;language&#39;=>&#39;en&#39;,
    &#39;options&#39;=>array(
                // &#39;show&#39; (the default), &#39;slideDown&#39;, &#39;fadeIn&#39;, &#39;fold&#39;
                &#39;showAnim&#39;=>&#39;fold&#39;,
                &#39;showOn&#39;=>&#39;button&#39;, // &#39;focus&#39;, &#39;button&#39;, &#39;both&#39;
                &#39;buttonText&#39;=>&#39;Select form calendar&#39;,
                &#39;buttonImage&#39;=>&#39;images/calendar.png&#39;,
                &#39;buttonImageOnly&#39;=>true,
                ),
            &#39;htmlOptions&#39;=>array(
                &#39;style&#39;=>&#39;width:80px;vertical-align:top&#39;
                ),
            ));
  
 ?>
 endWidget(); ?>
Copy after login

In order to obtain the input date, first assign a value to the Name attribute of CJuiDatePicker, in this case my_date, and then define the DataModel

class
 
DataModel extends CFormModel
{
    public $my_date;
}
Copy after login

When the user submits, display the date entered by the user and modify the actionIndex of SiteController

public function actionIndex()
{
  
    $model=new DataModel();
  
    if(!empty($_POST[&#39;my_date&#39;]))
    {
        $model->my_date=$_POST[&#39;my_date&#39;];
  
        if($model->validate()) {
            $this->render(&#39;result&#39;, array(
                &#39;model&#39; => $model,
  
                ));
           return;
        }
  
    }
  
    $this->render(&#39;index&#39;, array(
            &#39;model&#39; => $model,
  
            ));
}
Copy after login

PHP development framework Yii Framework tutorial (36) Zii component-DatePicker example

The above is the PHP development framework Yii Framework tutorial (36) Zii Contents of the component-DatePicker example. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!