Skip to content
This repository was archived by the owner on Feb 26, 2018. It is now read-only.
This repository was archived by the owner on Feb 26, 2018. It is now read-only.

Html input groups #33

Description

@daverdalas

Hey, I have not found a way to bind html input groups.
For example:

$builder->text('group[email]')

I did a little work around but it is not good piece of code :( but you can take a look :)

protected function nameToArray($str)
    {
        if (strpos($str,'[') === false) {
            return $str;
        }
        $re = "/(.*?)\\[(.*?)\\]/"; 
        preg_match_all($re, $str, $matches);
        array_shift($matches);
        $matches = array_filter(call_user_func_array('array_merge', $matches));
        $arr_string = "";
        foreach ($matches as $match)
        {
            $arr_string .= "['{$match}']";
        }
        return $arr_string;
    }
protected function hasModelValue($name)
    {
        if (is_array($this->model))
        {
            $name = $this->nameToArray($name);
            $arr = $this->model;
            eval('$isset = isset($arr'.$name.');');         
            return $isset;
        }
        if (! isset($this->model)) {
            return false;
        }
        return isset($this->model->{$name});
    }
protected function getModelValue($name)
    {
        if (is_array($this->model))
        {
            $name = $this->nameToArray($name);
            $arr = $this->model;
            eval('$val = $arr'.$name.';');  
            return $val;
        }
        return $this->model->{$name};
    }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions