Zebra_Form::assign PHP Method

assign() public method

create a new form $form = new Zebra_Form('my_form'); make available the $my_value variable in the template file $form->assign('my_value', '100'); don't forget to always call this method before rendering the form if ($form->validate()) { put code here } output the form notice that we are using a custom template my_template.php file is expected to be found and in this file, you may now use the $my_value variable $form->render('my_template.php');
public assign ( string $variable_name, mixed $value ) : void
$variable_name string Name by which the variable will be available in the template file. @param mixed $value The value to be assigned to the variable. @return void
$value mixed
return void
    function assign($variable_name, $value)
    {
        // save the variable in an array that we will make available in the template file upon rendering
        $this->variables[$variable_name] = $value;
    }