TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Kohana 3.0 ORM validation, get errors in view.
  • This is what i have in the controller :

    $problem->title = $_POST['title'];
    $problem->content = $_POST['content'];
    $problem->category = $_POST['category'];
    if($_POST['active']){
        $problem->active = '1';
        } else {
            $problem->active = '0';
        }
        $problem->lang = $_POST['lang'];
    
    
        if ($problem->check()) {
            $problem->save();
        }
        else {
            $errors = $problem->validate()->errors();
        }
    
    

    This in the Model :

    protected $_rules = array(
            'title' => array(
                'not_empty' => NULL,
            ),
    
            'content' => array(
                'not_empty' => NULL,
            ),
    
        );
    

    And this in the view :

        <?php if (isset($errors)): ?>
            <?php foreach ($errors as $error) : ?>
                <?php echo __($error); ?><br>
            <?php endforeach; ?>
        <?php endif; ?>
    

    But for some reason he does not show the errors. When there is an error the record is not saved so the 'Check' functions works.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion