Hello!
I am a newbie in Yii framework and also quite new to MVC programming so I am having an issue with an application that I’m working on.
I have two models OsnovnoSredstvo and Poseg. When I am doing new create in model Poseg I need to change date in model OsnovnoSredstvo. Now I have two problems:
- How can I dynamically change value of CJuiDatePicker with onchange of dropdown list?
_form for creating new Poseg:
The dropdownlist I’m changing.
<div class="row">
<?php echo $form->labelEx($model,'Inventarna'); ?>
<?php echo $form->dropDownList($model,'Inventarna',$model->getOsnovnoSredstvo(), array('empty'=>'Izberi osnovno sredstvo'));?>
<?php echo $form->error($model,'Inventarna'); ?>
</div>
The CJuiDatePicker that I want to change it’s value with the data from database
<div class="row">
<?php echo $form->labelEx(OsnovnoSredstvo::model(),'NRedni'); ?>
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>OsnovnoSredstvo::model(),
'name'=>'Model[test]',
'value'=>'2013-07-07',
// 'attribute'=>'NRedni',
'options'=>array(
'dateFormat'=>'yy-mm-dd',
'changeMonth'=>true,
'changeYear'=>true,
'showAnim'=>'fold', // 'show' (the default), 'slideDown', 'fadeIn', 'fold'
'showOn'=>'button', // 'focus', 'button', 'both'
'buttonText'=>Yii::t('ui','Select form calendar'),
'buttonImage'=>Yii::app()->request->baseUrl.'/images/calendar.gif',
'buttonImageOnly'=>true,
),
'htmlOptions'=>array(
'style'=>'width:80px;vertical-align:top'
),
)); ?>
<?php echo $form->error(OsnovnoSredstvo::model(),'NRedni'); ?>
</div>
- I have a problem when trying to save new poseg and update date in OsnovnoSredstvo. I am able to save data to Poseg, but I do not find a way to properly load model OsnovnoSredstvo and find the correct line in OsnovnoSredstvo
(findbypk($model->Inventarna))
and update the date NRedni to database. I have tried to change the actionCreate in controller Poseg or to add function afterSave in model Poseg. Looks like I have a problem with applying the right value of search paramerer Inventarna to either action or function.
I hope I wrote it down clearly and I hope my english is OK.
Thanks for any reply in advance. Maybe just with some suggestions of good examples, because I just don’t seem to find any that would make it clear to me.