• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.