PHP Development Framework Yii Framework Tutorial (+) zii component-datepicker sample

Source: Internet
Author: User
Tags yii

Cjuidatepicker is used for date input, which encapsulates the JUI DatePicker plug-in, and its basic usage is as follows:

<?php echo $form->errorsummary ($model);?>
 
 <?php
 $this->widget (' Zii.widgets.jui.CJuiDatePicker ', Array (
 	' name ' => ' my_date ',
 	' language ' => ' en ',
 	' options ' => Array (
	            ///' show ' (the default), ' Slidedown ', ' fadeIn ', ' fold '
 				showanim ' => ' fold ', ' Showon
 				' => ' Button ',//' Focus ', ' button ', ' both '
 				buttontext ' => ' Select form calendar ',
 				' buttonimage ' => ' images/ Calendar.png ',
 				' buttonimageonly ' =>true,
 				),
 			' Htmloptions ' =>array (
 				' style ' => ' width : 80px;vertical-align:top '
 				)
 			);
 
 ? >
<center class= "row Submit" >
    <?php echo Chtml::submitbutton (' submit ');?>
</ center>
 
<?php $this->endwidget ();?>
</center><!--form-->

To get the date entered, first assign a value to the Cjuidatepicker Name property, in this case my_date, and then define Datamodel

Class 

Datamodel extends Cformmodel
{public
	$my _date;
}

When the user submits, displays the date entered by the user, modifies the Sitecontroller Actionindex

Public Function Actionindex ()
{
 
	$model =new datamodel ();
 
	if (!empty ($_post[' my_date '))
	{
		$model->my_date=$_post[' my_date '];
 
		if ($model->validate ()) {
			$this->render (' result ', array (
				' model ' => $model,
 
				));
		   return;
		}
 
	$this->render (' index ', array (
			' model ' => $model
 
			);
}

See a full set of tutorials: http://www.bianceng.cn/webkf/PHP/201301/35265.htm

This example downloads: Http://www.imobilebbs.com/download/yii/DatePickerDemo.zip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.