public function edit($id) { $post = ORM::factory('blog_post', (int) $id); if (!$post->loaded) { message::error(__('Invalid ID'), 'admin/blog'); } $this->head->title->append(__('Edit: %title', array('%title' => $post->title))); $this->template->title .= __('Edit: %title', array('%title' => $post->title)); $form = Formo::factory()->plugin('csrf')->add('text', 'title', array('label' => __('Title'), 'value' => $post->title))->add('textarea', 'blog_content', array('label' => __('Content'), 'value' => $post->content))->add('text', 'tags', array('label' => __('Tags: <small>(Comma separated)</small>'), 'value' => $post->tags))->add('submit', 'submit', array('label' => __('Submit')))->add_rule('title', 'required', __('Please choose a title')); if ($form->validate()) { if ($form->title->value !== $post->title) { $post->uri = blog::unique_title($form->title->value); } $post->title = $form->title->value; $post->content = $form->blog_content->value; $post->tags = $form->tags->value; $post->save(); Cache::instance()->delete('s7n_blog_feed'); Cache::instance()->delete_tag('route'); message::info(__('Post edited successfully'), 'admin/blog/edit/' . (int) $id); } $this->template->content = View::factory('blog/edit', $form->get(TRUE)); $this->template->content->post = $post; }