Welcome Guest, Not a member yet? Register   Sign In
form helper callback is not working
#1

[eluser]johnmerlino[/eluser]
Hey all,

In this code:

Code:
// in views/partials/_contact.php
        echo contact_formatter('Your Name:','Add your name',"form_input()",'username');

// in helpers/layout_helper.php

    function contact_formatter($label,$text,$callback = null,$callback_arg){
        $str_builder = '';
        $str_builder .= "<div class='rowElem'>";
        $str_builder .= "<label>{$label}<span class='small'>{$text}</span></label>";
        $str_builder .= call_user_func($callback,$callback_arg); //(is_callable($callback)) ?
        $str_builder .= "</div>";
        return $str_builder;
    }

I get a php error:

Code:
Message: call_user_func() expects parameter 1 to be a valid callback, function 'form_input()' not found or invalid function name

thanks for response
#2

[eluser]johnmerlino[/eluser]
resolved it's 'format_input' not 'format_input()'. Like JavaScript, format_input is a reference to the function in memory position, whereas format_input() will execute it right away, despite it being wrapped in a string apparently.




Theme © iAndrew 2016 - Forum software by © MyBB