I’m currently working with Yii and I am very new to it , I’ve inherited code, I’m trying to add a radio button that will essentially use jQuery to grey out the type of box for text input in that row (technical and user) now I’ve got the heading in, the td with the row of buttons in. However I’ve been copying the already existing buttons and now I cant figure out how to change their labels and how to get them to interact with the jQuery.
The code:
<?php
/* @var $serviceTasks array */
?>
<table id="service-task-table" class="service-task-table">
<thead>
<tr>
<th>
Task
</th>
<th>
Pass
</th>
<?php if ((!empty($serviceTasks[0]) && get_class($serviceTasks[0]) == 'AssetServiceTask') || (!empty($serviceTasks[0]->workOrder) && $serviceTasks[0]->workOrder->showOldTaskNotes())) { ?>
<th>
Note
</th>
<?php } else if (!empty($serviceTasks[0]) && $serviceTasks[0]->hasAttribute('technical_note')) { ?>
<th>
Type of Note
</th>
<th>
Technical Note
</th>
<th>
User Note
</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
$specNames = array();
foreach ($serviceTasks as $i => $serviceTask) {
if (!empty($serviceTask->serviceTask->default_value) && empty($serviceTask->value)) {
$serviceTask->value = $serviceTask->serviceTask->default_value;
}
?>
<?php
if (!in_array($serviceTask->serviceTask->serviceSpecification->name, $specNames)) {
?>
<tr>
<td colspan="4">
<h3><?= $serviceTask->serviceTask->serviceSpecification->name ?></h3>
</td>
</tr><?php
$specNames[] = $serviceTask->serviceTask->serviceSpecification->name;
}
?>
<tr class="task-row">
<td>
<?php echo $serviceTask->serviceTask; ?>
<?php echo $form->hiddenField($serviceTask, "[$i]id"); ?>
</td>
<td>
<?php if ($serviceTask->serviceTask->service_task_outcome_id == ServiceTaskOutcome::PASS_FAIL_NA_ID): ?>
<?php echo $form->textField($serviceTask, "[$i]pass", array('class' => 'pass-fail-box', 'maxlength' => '1')); ?> P / F / N (N = N/A)
//THESE ARE THE LABELS FOR THE BUTTONS
<?php echo $form->textField($serviceTask, "[$i]value", array('class' => 'pass-fail-box', 'maxlength' => '1')); ?> User Note / Technical Note
<?php elseif ($serviceTask->serviceTask->service_task_outcome_id == ServiceTaskOutcome::VALUE_ID): ?>
<?php echo $form->textField($serviceTask, "[$i]value", array('maxlength' => '45')); ?>
<?php
if (!empty($serviceTask->serviceTask->unit_of_measure_id)) {
echo $serviceTask->serviceTask->unitOfMeasure;
}
?>
<?php elseif ($serviceTask->serviceTask->service_task_outcome_id == ServiceTaskOutcome::DATE_VALUE_ID): ?>
<?php
$form->widget('MyJuiDatePicker', array(
'model' => $serviceTask,
'attribute' => "[$i]value",
'value' => $serviceTask->value,
'options' => array(
'showButtonPanel' => true,
'changeYear' => true,
'dateFormat' => 'yy-mm-dd',
),
));
?>
<?php elseif ($serviceTask->serviceTask->service_task_outcome_id == ServiceTaskOutcome::VALIDATION_ID): ?>
<div class="no-style-list">
<?php echo $form->radioButtonList($serviceTask, "[$i]value", ServiceTaskOutcome::getValidationOptions()); ?>
</div>
<?php elseif ($serviceTask->serviceTask->service_task_outcome_id == ServiceTaskOutcome::LIST_SELECTION_ID): ?>
<?php if ($serviceTask->serviceTask->single_selection && count($serviceTask->serviceTask->serviceTaskOutcomeOptions) <= 3): ?>
<div class="no-style-list">
<?php
//Use value[0] for radio button list values
echo $form->radioButtonList($serviceTask, "[$i]value[0]", MyHtml::listDataEx($serviceTask->serviceTask->serviceTaskOutcomeOptions, 'name', 'name'));
?>
</div>
<td style="width: 5px;">
<div class="no-style-list">
<?php
echo $form->radioButtonList($serviceTask, "[$i]value[0]", MyHtml::listDataEx($serviceTask->serviceTask->serviceTaskOutcomeOptions, 'name', 'name'));
?>
</div>
</td>
<?php else: ?>
<?php echo $form->dropDownList($serviceTask, "[$i]value[0]", MyHtml::listDataEx($serviceTask->serviceTask->serviceTaskOutcomeOptions, 'name', 'name'), array(!$serviceTask->serviceTask->single_selection ? 'multiple' : 'single' => !$serviceTask->serviceTask->single_selection ? 'multiple' : '', 'class' => 'filterable')); ?>
<?php endif; ?>
<?php elseif ($serviceTask->serviceTask->service_task_outcome_id == ServiceTaskOutcome::ASSET_VALUE_ID): ?>
<?php echo $form->textField($serviceTask, "[$i]value", array('maxlength' => '45')); ?>
<?php endif; ?>
<?php echo $form->error($serviceTask, "[$i]value"); ?>
</td>
<?php if ((!empty($serviceTask) && get_class($serviceTask) == 'AssetServiceTask') || (!empty($serviceTask->workOrder) && $serviceTask->workOrder->showOldTaskNotes())) { ?>
<td>
<?php echo $form->textArea($serviceTask, "[$i]note", array('class' => 'note')); ?>
<?php echo $form->error($serviceTask, "[$i]note"); ?>
</td>
<?php } else if ($serviceTask->hasAttribute('technical_note')) { ?>
<td>
<?php echo $form->textArea($serviceTask, "[$i]technical_note", array('class' => 'note')); ?>
<?php echo $form->error($serviceTask, "[$i]technical_note"); ?>
</td>
<td>
<?php echo $form->textArea($serviceTask, "[$i]user_note", array('class' => 'note')); ?>
<?php echo $form->error($serviceTask, "[$i]user_note"); ?>
</td>
<?php } ?>
<td>
<?php if (!empty($serviceTask->serviceTask->serviceTaskProcesses)): ?>
<a class="processMap" class="pull-right"
href="<?= $this->createUrl('process', array('workOrderServiceTaskId' => $serviceTask->id)); ?>"><img
src="<?= Yii::app()->baseUrl . '/images/modelIcons/process.png' ?>"/></a>
<?php endif; ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="hidden" id="certificate"></div>
<?php
Yii::app()->clientScript->registerScript('passFailCheck', "
$(document).ready(function(){
$('.pass-fail-box').keyup(function(){
if(!($(this).val().toLowerCase() == 'p' || $(this).val().toLowerCase() == 'f' || $(this).val().toLowerCase() == 'n')){
$(this).val('');
}
else if($(this).val().toLowerCase() == 'f'){
$(this).closest('td').next().find('.note').focus();
}
else if($(this).val().toLowerCase() == 'p' || $(this).val().toLowerCase() == 'n'){
$(this).closest('tr').next().find('.pass-fail-box').focus();
}
});
$('.processMap').click(function(){
openDialog($(this).attr('href'),'Process', 'ProcessMapDialog');
return false;
});
});
");
//JQUERY HERE FOR GREYING OUT THE USER NOTE AND TECHNICAL NOTE DEPENDING WHAT HAS BEEN CLICKED
Yii::app()->clientScript->registerScript('userTechnicalNote', "
$(document).ready(function(){
");
?>