How To Get The Id Of The Primary Table In The Secondary Table Form Field.

Hi guys.

I have to tables Jobs and Applicants. From admin side I will create a new job. and on the front end I will display that jobs. on the job detail page there is an online apply button which will move you to the applicant form where a candidate can apply online. now on the applicant page I want to show the title of the job in a text field (which I will disabled so that its value can’t be changed).

How should to do this ?

here is my code.

[Job detail page code]

5577

job-page.png




                        <h1> <?php echo $model->title; ?></h1>

                        <?php echo CHtml::link(CHtml::encode('Apply Online'), array('/applicant/create', 'id' => $model->id), array('class' => 'btn btn-success  pull-right')); ?>

                   

[and here is applicant form]

5578

applicant.png




<div class="container">

    <?php

    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(

        'id' => 'applicant-form',

        'enableAjaxValidation' => false,

        'htmlOptions' => array('enctype' => 'multipart/form-data'),

        'type' => 'horizontal'

    ));

    ?>


    <p class="help-block">Fields with <span class="required">*</span> are required.</p>


    <?php echo $form->errorSummary($model); ?>


    <div class="row-fluid">

        <div class="span6">


            <?php echo $form->textFieldRow($model->id, 'job_id', array('class' => 'span10', 'maxlength' => 256, 'disabled' => true)); ?>

            <?php echo $form->textFieldRow($model, 'name', array('class' => 'span10', 'maxlength' => 200)); ?>

            <?php echo $form->textFieldRow($model, 'father_name', array('class' => 'span10', 'maxlength' => 200)); ?>

            <?php echo $form->textFieldRow($model, 'email', array('class' => 'span10', 'maxlength' => 200)); ?>

       

        </div>




    </div>

    <div class="pull-right">


        <?php

        $this->widget('bootstrap.widgets.TbButton', array(

            'buttonType' => 'submit',

            'type' => 'primary',

            'label' => $model->isNewRecord ? 'Submit' : 'Save',

        ));

        ?>


    </div>

</div>


<?php $this->endWidget(); ?>




Thanks in advance.

Try to use ajax method to pass the data.




'ajax' => array(

	                              'datatype'=>'JSON', 

	                              'type'=>'POST', 

	                              'url'=>$this->createurl('Mstleave/getdays'),  ////url to call   

	                              'data'=> array('ToDate'=>'js:$("#ToDate").val()','FromDate'=>'js:$("#FromDate").val()'),

	                              )

					),



If you’re using Bootstrap (which it looks like you are), you can use an uneditable field, which essentially outputs text rather than a form field.

Yes I am using bootstrap.

I have tried but not working i.e. the value is not displaying in the uneditable field.

and I am confused that where is the problem.

You need to pass the relevant Job model into the view and show the appropriate field from that.

I have share the code.

Would you please sort it for me .