我正在尝试编辑数据库中的值,但出现以下错误:
Call to a member function values() on a non-object
控制器
public function action_options() {
$this->template->styles = array(
'style' => 'style',
'acp' => 'acp'
);
$options = ORM::factory('option')->find_all()->as_array('option_name','option_value');
$this->template->content = View::factory('default/admin/options')
->bind('options', $options);
}
public function action_savesettings() {
$options = ORM::factory('option')->find_all()->as_array('option_name','option_name');
$options->values($this->request->post());
$errors = array();
try {
$options->save();
$this->request->redirect('acp/options');
} catch (ORM_Validation_Exception $ex) {
$errors = $ex->errors('validation');
}
$this->template->content = View::factory('default/admin/options')
->bind('options', $options)
->bind('errors', $errors);
}
看法
<?php $errors = isset($errors) ? $errors : array(); ?>
<?php echo Form::open('acp/savesettings'); ?>
Site Name: <?php echo Form::input('site_name', $options['site_name'], array('id' => 'acp-sitename')); ?><br />
<?php echo Form::submit('submit', 'Submit', array('id' => 'acp-submit')); ?>
<?php echo Form::close(); ?>
我的桌子是这样的:
option_id option_name option_value
我不确定如何处理这个问题,因为我正在使用 $options[''] 访问和编辑这些值。