javascriptnya
<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery/jquery.selectbox-0.5.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.styledselect').selectbox({ inputClass: "selectbox_styled" });
});
</script>
<![endif]>
<!-- styled select box script version 2 -->
<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery/jquery.selectbox-0.5_style_2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.styledselect_form_1').selectbox({ inputClass: "styledselect_form_1" });
$('.styledselect_form_2').selectbox({ inputClass: "styledselect_form_2" });
});
</script>
<!-- styled select box script version 3 -->
<script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery/jquery.selectbox-0.5_style_2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.styledselect_pages').selectbox({ inputClass: "styledselect_pages" });
});
</script>
view
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'lksa-data-form',
'enableAjaxValidation'=>true,
'htmlOptions'=>array('enctype'=>'multipart/form-data'),
));
?>
<div class="clear"></div>
<?php echo $form->errorSummary($model); ?>
<table border="0" cellpadding="0" cellspacing="0" id="id-form">
<tr>
<th valign="top">Nama Lksa <span class="required">*</span> :</th>
<td><?php echo $form->textField($model,'lksa_name',array('size'=>30,'maxlength'=>30,'class'=>'inp-form')); ?>
</td>
<td>
<?php echo $form->error($model,'lksa_name',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">Alamat <span class="required">*</span> :</th>
<td><?php echo $form->textArea($model,'address',array('size'=>30,'maxlength'=>30,'class'=>'form-textarea')); ?>
</td>
<td>
<?php echo $form->error($model,'address',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">Nama Kabupaten <span class="required">*</span> :</th>
<td>
<?php
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'LksaData[regency_id]',
'value'=>isset($model->regency)?$model->regency->regency_name:"",
'id'=>'regency-id',
'name'=>'regency_id',
'source'=>$this->createUrl('LksaData/suggestRegency'),
'htmlOptions'=>array(
'class'=>'inp-form'
),
));
?>
</td>
<td>
<?php echo $form->error($model,'regency_id',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">Email <span class="required">*</span> :</th>
<td><?php echo $form->textField($model,'email',array('size'=>30,'maxlength'=>30,'class'=>'inp-form')); ?>
</td>
<td>
<?php echo $form->error($model,'email',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">Pimpinan <span class="required">*</span> :</th>
<td><?php echo $form->textField($model,'leader',array('size'=>30,'maxlength'=>30,'class'=>'inp-form')); ?>
</td>
<td>
<?php echo $form->error($model,'leader',array('class'=>'error-inner')); ?>
</td>
</tr>
//disini yg muncul 2 kali
<tr>
<th valign="top">Status Kepemilikan <span class="required">*</span> :</th>
<td><?php echo CHtml::activeDropdownList($model, 'ownership_status_id', Chtml::listData(OwnershipStatus::model()->findAll(), 'id', 'owner'),$htmlOptions=array('class'=>'styledselect_form_1','width'=>'100')); ?></td
<td>
<?php echo $form->error($model,'ownership_status_id',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">Contact Person <span class="required">*</span> :</th>
<td><?php echo $form->textField($model,'contact_person',array('size'=>30,'maxlength'=>30,'class'=>'inp-form')); ?>
</td>
<td>
<?php echo $form->error($model,'contact_person',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">No Handphone <span class="required">*</span> :</th>
<td><?php echo $form->textField($model,'handphone_number',array('size'=>30,'maxlength'=>30,'class'=>'inp-form')); ?>
</td>
<td>
<?php echo $form->error($model,'handphone_number',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">Akta Notaris <span class="required">*</span> :</th>
<td><?php echo $form->textField($model,'notarial_deed',array('size'=>30,'maxlength'=>30,'class'=>'inp-form')); ?>
</td>
<td>
<?php echo $form->error($model,'notarial_deed',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">NPWP <span class="required">*</span> :</th>
<td><?php echo $form->textField($model,'npwp',array('size'=>30,'maxlength'=>30,'class'=>'inp-form')); ?>
</td>
<td>
<?php echo $form->error($model,'npwp',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">SIOP <span class="required">*</span> :</th>
<td><?php echo $form->textField($model,'siop',array('size'=>30,'maxlength'=>30,'class'=>'inp-form')); ?>
</td>
<td>
<?php echo $form->error($model,'siop',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">Nama Bank <span class="required">*</span> :</th>
<td><?php echo $form->textField($model,'bank_account',array('size'=>30,'maxlength'=>30,'class'=>'inp-form')); ?>
</td>
<td>
<?php echo $form->error($model,'bank_account',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">Nama Pemilik Rekening <span class="required">*</span> :</th>
<td><?php echo $form->textField($model,'name_account',array('size'=>30,'maxlength'=>30,'class'=>'inp-form')); ?>
</td>
<td>
<?php echo $form->error($model,'name_account',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">No Rekening <span class="required">*</span> :</th>
<td><?php echo $form->textField($model,'account_number',array('size'=>25,'maxlength'=>25,'class'=>'inp-form')); ?>
</td>
<td>
<?php echo $form->error($model,'account_number',array('class'=>'error-inner')); ?>
</td>
</tr>
<tr>
<th valign="top">Buku Rekening <span class="required">*</span> :</th>
<td><?php echo $form->fileField($model,'picture',array('size'=>30,'maxlength'=>30,'class'=>'file_1')); ?>
</td>
<td>
<?php echo $form->error($model,'picture',array('class'=>'error-inner','visible'=>$model->isNewRecord)); ?>
</td>
</tr>
<tr>
<th> </th>
<td valign="top">
<?php //echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'),$htmlOptions=array('class'=>'form-submit');
echo CHtml::submitButton('', $htmlOptions=array('class'=>'form-submit'));
?>
</td>
<td></td>
</tr>
<?php $this->endWidget(); ?>
</table>
</div><!-- form -->
controller
public function actionCreate()
{
$model=new LksaData;
$this->layout='//layouts/layout1';
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if(isset($_POST['LksaData']))
{
$model->attributes=$_POST['LksaData'];
$model->picture = CUploadedFile::getInstance($model,'picture');
//else $this->addError('regency_id','Masukkan Kabupaten');
$model->year =date('Y-n-j');
if($model->regency_id!=null)
{
$regency=Regency::model()->findByAttributes(array('regency_name'=>$model->regency_id));
$model->regency_id=$regency->id;
$count=count(LksaData::model()->findAllByAttributes(array('regency_id'=>$model->regency_id,)))+1;
$buntut=" ";
if($count<9 &&$count!=0)$buntut="00".$count;
elseif($count<99&&$count>10)$buntut="0".$count;
$model->lksa_code=$model->regency->province->province_code.".".$model->regency->regency_code.".".$buntut;
}
$path_product = Yii::app()->getBasePath().'/../images/accountPicture/';
if($model->save()){
// var_dump($model->lksa_code);
// die();
$model->picture->saveAs($path_product . $model->picture->name);
//var_dump($buntut);die();
$lksaDataHeader = new LksaDataHeader;
$lksaDataHeader->registration_number="LKSA ".$model->lksa_code.".".$this->randomStringBook();
$lksaDataHeader->lksa_data_id=$model->id;
$lksaDataHeader->register_date =date('Y-n-j');
$lksaDataHeader->save();
$documentLksaDataHeader= new DocumentLksaDataConfirmation;
$documentLksaDataHeader->lksa_data_header_id=$lksaDataHeader->id;
$documentLksaDataHeader->save();
$this->redirect(array('childData/create','id'=>$lksaDataHeader->id));
}
// var_dump($model->getErrors());
// die();
$this->render('create',array('model'=>$model,));
}
$this->render('create',array(
'model'=>$model,
));
}