Welcome Guest, Not a member yet? Register   Sign In
loading my own library into helper function
#1

Hello.

i have function form()
{
    # there is where i would like to load my library into $form_ variable
 $form_ = service('Form'); <- this doesn't work - my app/libraries/form library
 $timer = service('Timer'); <- this works - ci service
dd($form_);

}

how can i load instance of ci into this helper function?

Second question: I created app/libraries/Form.php library

<?php namespace App\Libraries;

class Form
{
    protected $validation = false;

    public function __construct()
    {
    $this->validation = [];
       
    }

    public function validations()
    {
    $this->validation['peter'] = 'test';
        return $this->validation;
    }

    public function add($name,$rules)
    {
    echo "OKa";
    die;
    $this->validation[$name] = $rules;
    }

}


how can i load this library in my helper function form?
Reply
#2

$validation = new Application\Libraries\Form;
when i try to call it like this, it does not work.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB