Exemplo n.º 1
0
/**
 * faq_edit 
 * 
 * @param string $id unique identifier for te FAQ
 *
 * @access public
 * @return string
 */
function faq_edit($id)
{
    $data = array();
    $faq = Faq::fetch($id);
    if (!$faq) {
        throw new NotFoundException();
    }
    if (is_post()) {
        $faq->fromArray($_POST);
        if ($faq->isValid()) {
            $faq->save();
            return redirect('/faq/list');
        } else {
            $data['errors'] = array();
            $data['errors']['faq'] = format_error($faq);
        }
    }
    $data['faq'] = $faq;
    return render('faq_form.tpl', $data);
}