我无法回显在视图中从控制器返回的数据。控制器正在返回正确的数据。即print_r($ data ['notice_period']); 死;返回
下面的数组
Array ( [0] => Array ( [id] => 1 [userid] => 1 [emp_code] => 047 [emp_shift] => 2nd Shift [emp_category] => Full Time [cccode] => [prefix] => Dr. [firstname] => admin [middlename] => [lastname] => unfold [designation_id] => 8 [division_id] => [branch_id] => 4 [company] => [email] => admin@unfold.com [personal_email] => [nickname] => [url] => [birthday] => 18-03-1980 [panno] => [passportno] => [passportdate] => [joining_date] => 14-07-2016 [resignation_date] => 01-01-1970 [team_id] => [tag_ids] => [im] => [facebook] => [twitter_handle] => [linkedin_id] => [instagram] => [googleplus] => [maidenname] => [profileimage] => 1458813725_421139936.jpg [blood_group] => A Positive [gender] => Male [married] => [anniversary] => 24-06-2009 [ctc] => [mood] => Happy toda [doc_type] => [org_to] => [org_from] => [org] => [role_title] => [org_skills] => [scanned_doc_work] => [pass_year] => [adm_year] => [degree] => [univ] => [edu_scanned_doc] => [declare_home] => 1 [declare_menu1] => 1 [declare_family] => 1 [declare_menu4] => 1 [declare_menu7] => 1 [declare_menu8] => 1 [declare_menu2] => [declare_menu3] => [s_cluster_id] => 2 [status] => 1 [deleted] => 0 [registrationtime] => 0 [timemodified] => 0 [modifierid] => 0 [alternate_email] => [notice_period] => 10 ) )
我正在尝试在只读文本框中打印通知期但失败了。这是我的观看代码:
<?php echo form_input(array("name" =>"notice_period" ,"id"=>"notice_period","class"=>"m-wrap form-control ","value"=>$data->notice_period))?>
我的控制器代码是:
$data['notice_period']=$this->exit_common->get_notice_period($USER);
$this->data['maincontent'] = $this->load->view('maincontents/exit_add_view', $data,true);
$this->load->view('layout', $this->data);
如何在我的视图中打印通知期?它显示空白
edit_add_view.php
<!-- Main content -->
<!-- Content Wrapper. Contains page content -->
<!-- Content Header (Page header) -->
<style>
tr > td
{
padding-bottom: 1em;
}
</style>
<section class="content-header">
<h1>
Add Resignation Request
</h1>
<ol class="breadcrumb">
<li><a href="<?php base_url(); ?>"><i class="fa fa-home"></i> Home</a></li>
<li><a href="#">My Requests</a></li>
<li><a href="<?php echo base_url(); ?>exits/resignation_request">Resignation Requests</a></li>
<li class="active">Add Resignation Request</li>
</ol>
</section>
<div class="container-fluid">
<div class="row">
<!-- Thought Day-->
<div class="panel wrapper clearfix m-b-none">
<div class="panel-body">
<input type="hidden" id="page_name" value="requests">
<?php if($error_message!=''){?>
<div class="success-message <?php echo $msg_class;?>"><?php echo $error_message;?> </div>
<?php } else { ?>
<?php $row = $rows[0] ;
if(isset($row['grievance_type'])) {
$grievancetype = $row['grievance_type'];
} else { $grievancetype = ''; }
?>
<!-- form start -->
<?php echo form_open('exits/my_resignation_request/'.$id,array('name'=>'addostcstevent','id'=>'addostcstevent','method'=>'post','autocomplete'=>'on','class'=>'form-horizontal'))?>
<?php echo form_hidden(array('id'=>$row->id,'action'=>$action));?>
<div class="box-body">
<input type="hidden" name="todays_date" readonly id="todays_date" value="<?php echo date('m/d/y');?>" class="form-control col-md-10" <?php if($USER->permissions[0] != 'all') { ?> readonly <?php } ?>>
<table class="table table-striped" style="margin-top:40px">
<td>
<?php echo form_input(array("name" =>"notice_period" ,"id"=>"notice_period","class"=>"m-wrap form-control ","value"=>$data->notice_period))?>
</td>
<thead>
<tr>
<th><input placeholder="Date of Request" id="dateofrequest" type="button" name="todays_date" value="Date of request: <?php echo date('m/d/y');?>" readonly/></th>
<th><input placeholder="Status" id="status" type="button" name="status" value="Status: Processing" readonly/></th>
</tr>
</thead>
<tbody>
<tr>
<td><label>Reason</label></td>
<td>
<select name="reason" class="form-control">
<?php
foreach($reasons as $row)
{
echo '<option value="'.$row->reasons.'">'.$row->reasons.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td><label>Requested Last Working Day</label></td>
<td><div class="date" data-date="12-02-2012" data-date-format="mm-dd-yyyy" data-date-viewmode="years">
<input placeholder="Requested Last working day" class="col-md-4 form-control " id="startdt" type="text" name="requested_date" value="" required/></td>
</tr>
<tr>
<td><label>Comments</label></td>
<td><textarea required class="form-control" name="comments"></textarea></td>
</tr>
</tbody>
</table>
</div><!-- /.box-body -->
<div class="box-footer">
<?php
echo form_hidden('action',$action);
echo form_hidden('id',$id);
?>
<!--<button type="submit" class="btn btn-info pull-right" name="withdraw" style="margin:0px 10px" value="withdrawn">Withdraw Resignation</button>-->
<button type="submit" class="btn btn-info pull-right" style="margin:0px 10px">Submit</button>
</div><!-- /.box-footer -->
</form>
<?php } ?>
</div><!-- /.box -->
</div><!--/.col (right) -->
</div> <!-- /.row -->
<div class="modal fade" role="dialog" id="myLTAModal">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Alert!</h4>
</div>
<div class="modal-body">
<!-- modal content-->
<div class="panel-body">
<p>Ensure you refer to LTA guidelines before planning your trip. You will be required to submit your tickets as proof to avail LTA.</p>
</div>
</div>
<!-- modal content-->
</div>
</div>
</div>
<div class="modal fade" role="dialog" id="leaveAllowedModal">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Alert!</h4>
</div>
<div class="modal-body">
<!-- modal content-->
<div class="panel-body">
<p class="allowed_text"></p>
</div>
</div>
<!-- modal content-->
</div>
</div>
</div>
</section><!-- /.content -->
<script>
/*$(document).ready(function(){
$('#reservation').daterangepicker();
})*/
</script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script>
function parseDate(str) {
var mdy = str.split('/')
return new Date(mdy[2], mdy[0]-1, mdy[1]);
}
function daydiff(first, second) {
return Math.round((second-first)/(1000*60*60*24));
}
$(document).ready(function(){
$("#startdt").datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: "-90:+0",
startDate: new Date(),
autoclose: true
}).on('changeDate', function (selected) {
var minDate = new Date(selected.date.valueOf());
$('#enddt').datepicker('setStartDate', minDate);
});
$("#enddt").datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: "-90:+0"
});
$("#enddt").change(function(){
if($("#startdt").val()!='' && $("#enddt").val()!='')
{
var startdt = $("#startdt").val();
var enddt = $("#enddt").val();
$("#daysleave").val(daydiff(parseDate(startdt), parseDate(enddt)));
if($("#grievance_type").val()!='0')
{
var day_diff_today = daydiff(parseDate($("#today_dt").val()), parseDate($("#startdt").val()));
if(((parseInt($("#daysleave").val()) > parseInt($("#grievance_type option:selected").attr("data-min"))) && (parseInt($("#daysleave").val()) < parseInt($("#grievance_type option:selected").attr("data-max"))))&&(day_diff_today > parseInt($("#grievance_type option:selected").attr("data-approvaldays"))))
{ } else {
$("#leaveAllowedModal").modal("show");
}
}
}
})
$("#grievance_type").change(function(){
if($("#startdt").val()!='' && $("#enddt").val()!='' && $("#grievance_type").val()!='0')
{
var day_diff_today = daydiff(parseDate($("#today_dt").val()), parseDate($("#startdt").val()));
if(((parseInt($("#daysleave").val()) > parseInt($("#grievance_type option:selected").attr("data-min"))) && (parseInt($("#daysleave").val()) < parseInt($("#grievance_type option:selected").attr("data-max"))))&&(day_diff_today > parseInt($("#grievance_type option:selected").attr("data-approvaldays"))))
{ } else {
$("#leaveAllowedModal").modal("show");
}
}
})
$(".date-picker").datepicker();
$("#optionsRadios1").click(function(){
$("#myLTAModal").modal("show");
})
$('#leaveAllowedModal').on('shown.bs.modal', function() {
var msg = '';
if((parseInt($("#daysleave").val()) > parseInt($("#grievance_type option:selected").attr("data-min"))) && (parseInt($("#daysleave").val()) < parseInt($("#grievance_type option:selected").attr("data-max"))))
{ } else {
msg = msg + "You wish you apply "+$("#daysleave").val()+" day of "+$("#grievance_type option:selected").text()+". Minimum and Maximum no. of Leaves allowed to take at a time are "+$("#grievance_type option:selected").attr("data-min")+" and "+$("#grievance_type option:selected").attr("data-max")+" respectively.";
}
var day_diff_today = daydiff(parseDate($("#today_dt").val()), parseDate($("#startdt").val()));
if((day_diff_today < parseInt($("#grievance_type option:selected").attr("data-approvaldays"))))
{
msg = msg + " No. of days of prior approval needed is " + $("#grievance_type option:selected").attr("data-approvaldays") + " days";
}
$(".allowed_text").html(msg);
})
});
</script>
答案 0 :(得分:1)
您必须将数组传递给视图。 CodeIgniter自动使数组键可用作变量。这意味着您只需使用$notice_period
而不是$data->notice_period