Отказ от ответственности: я новичок в веб-разработке.
Кажется, я не могу понять, что не так в этой ситуации, когда я использую JavaScript для отображения информации при нажатии на элемент списка.Я объявил свою переменную в контроллере, но я получаю неопределенную ошибку переменной вместе со свойством Get свойства Non-Object Error.Какие-нибудь мысли?Большое спасибо за вашу помощь!
Вот сообщения об ошибках:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: event
Filename: user/planner_view.php
Line Number: 27
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: user/planner_view.php
Line Number: 27
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: event
Filename: user/planner_view.php
Line Number: 29
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: user/planner_view.php
Line Number: 29
Status
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: status_options
Filename: user/planner_view.php
Line Number: 32
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: event
Filename: user/planner_view.php
Line Number: 32
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: user/planner_view.php
Line Number: 32
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: helpers/form_helper.php
Line Number: 331
Title
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: event
Filename: user/planner_view.php
Line Number: 37
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: user/planner_view.php
Line Number: 37
Вот контроллер:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Planner extends Common_Auth_Controller {
private $end_user;
public function __construct()
{
parent::__construct();
$this->end_user = $this->ion_auth->user()->row();
$data['end_user'] = $this->end_user;
$this->load->vars($data);
$this->load->model('events_model', 'events');
}
public function populate_events()
{
$this->load->model('events_model', 'events');
$this->events->populate_events($this->end_user->id);
}
public function index()
{
$config['start_day'] = 'sunday';
$config['month_type'] = 'long';
$config['day_type'] = 'long';
$config['show_next_prev'] = TRUE;
$config['next_prev_url'] = base_url('user/planner/index/');
$config['template'] = '
{table_open}<table class="planner">{/table_open}
{heading_row_start}<tr>{/heading_row_start}
{heading_previous_cell}<th><a href="{previous_url}"><<</a></th>{/heading_previous_cell}
{heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
{heading_next_cell}<th><a href="{next_url}">>></a></th>{/heading_next_cell}
{heading_row_end}</tr>{/heading_row_end}
{week_row_start}<tr>{/week_row_start}
{week_day_cell}<th class="day_header">{week_day}</td>{/week_day_cell}
{week_row_end}</tr>{/week_row_end}
{cal_row_start}<tr>{/cal_row_start}
{cal_cell_start}<td>{/cal_cell_start}
{cal_cell_content}<span class="day_listing">{day}</span><ul class="event_list">{content}</ul>{/cal_cell_content}
{cal_cell_content_today}<div class="today"><span class="day_listing">{day}</span><ul class="event_list">{content}</ul>{/cal_cell_content_today}
{cal_cell_no_content}<span class="day_listing">{day}</span> {/cal_cell_no_content}
{cal_cell_no_content_today}<div class="today"><span class="day_listing">{day}</span></div>{/cal_cell_no_content_today}
{cal_cell_blank} {/cal_cell_blank}
{cal_cell_end}</td>{/cal_cell_end}
{cal_row_end}</tr>{/cal_row_end}
{table_close}</table>{/table_close}
';
$this->load->library('calendar', $config);
$title['title'] = 'Planner';
$data = $this->events->get_events_for_calendar($this->end_user->id, $this->uri->segment(4), $this->uri->segment(5));
$calendar['calendar'] = $this->calendar->generate($this->uri->segment(4), $this->uri->segment(5), $data);
$this->load->view('public/head_view', $title);
$this->load->view('user/header_view');
$this->load->view('user/planner_view', $calendar);
$this->load->view('user/footer_view');
}
public function update($event_id)
{
if($_POST)
{
$title = $this->input->post('title');
$status = $this->input->post('status');
$content = $this->input->post('content');
$data = array(
"id" => $event_id,
"title" => $title,
"status" => $status,
"content" => $content
);
if ($this->events->update($data))
{
echo "YAY";
}
else
{
echo "CRAP";
}
}
else
{
$data = array();
$data['event'] = $this->events->get($event_id);
$data['status_options'] = array(
NULL => "Select",
"C" => "Completed",
"L" => "Completed Late",
"N" => "Not Completed"
);
echo $this->load->view("user/planner_view", $data, TRUE);
}
}
}
Вот вид:
<?php echo form_open('user/planner/update/'.$event->id, 'id="updateForm"'); ?>
<h3><?php echo $event->type ?></h3>
<label for="status">Status</label>
<?php echo form_dropdown('status', $status_options, $event->status ) ?>
<br/>
<br/>
<label for="title">Title</label>
<input type="text" id="title" name="title" value="<?php echo $event->title ?>" />
<br/>
<br/>
<label for="content">Content</label>
<textarea id="content" name="content"><?php echo $event->content ?></textarea>
<br/>
<br/>
<p><?php echo form_submit('submit','Save') ?>
<?php echo form_close(); ?>