[TUTORIAL YII] CARA MEMBUAT DATEPICKER DENGAN CJUIDATEPICKER
Buat tabel.
DROP TABLE IF EXISTS `book`; CREATE TABLE `book` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` VARCHAR(256) NOT NULL, `type_id` int(10) unsigned, `publication_date` date, `value` decimal(10,2), `price` decimal(10,2), -- image - link -- issue info `notes` text, `signed` boolean, `grade_id` int(10) unsigned, `bagged` boolean, PRIMARY KEY (`id`), CONSTRAINT FOREIGN KEY (`type_id`) REFERENCES `type` (`id`), CONSTRAINT FOREIGN KEY (`grade_id`) REFERENCES `grade` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Buat Model dan CRUD menggunakan Gii.
views/book/_form.php
<div class="row"> <?php echo $form->labelEx($model,'publication_date'); ?> <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array( 'name' => 'publication_date', 'attribute' => 'publication_date', 'model'=>$model, 'options'=> array( 'dateFormat' =>'yy-mm-dd', 'altFormat' =>'yy-mm-dd', ), )); ?> <?php echo $form->error($model,'publication_date'); ?> </div>
No comments:
Post a Comment