Exemplo n.º 1
0
use app\models\Institute;
use app\models\Course;
use kartik\datetime\DateTimePicker;
/* @var $this yii\web\View */
/* @var $model app\models\BlockTime */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="block-time-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'institute')->dropdownList(institute::find()->select(['name', 'id'])->indexBy('id')->column(), ['prompt' => 'Select Institute', 'onchange' => '$.post( "index.php?r=institute/courses&id=" +$(this).val(), function( data ) {
                                $( "select#blocktime-course_id" ).html( data );
                           });']);
?>

    <? if($model->institute != null){
    echo $form->field($model,'course_id')->dropdownList(
        Course::find()->where(['institute_id'=>$model->institute->id])->select(['name','id'])->indexBy('id')->column(),
        [
            'prompt' => 'Select Courses',
        ]);
    }
    else{
        echo $form->field($model,'course_id')->dropdownList(
        [],
        [
Exemplo n.º 2
0
/* @var $form yii\widgets\ActiveForm */
?>

<div class="course-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?/*= $form->field($model, 'institute_id')->textInput() */?>

    <?php 
echo $form->field($model, 'institute_id')->dropdownList(institute::find()->select(['name', 'id'])->indexBy('id')->column(), ['prompt' => 'Select Institute']);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>