lithium\template\helper\Form::binding PHP Method

binding() public method

Returns the entity that the Form helper is currently bound to.
See also: lithium\template\helper\Form::$_binding
public binding ( string $name = null ) : object
$name string If specified, match this field name against the list of bindings
return object Returns an object, usually an instance of `lithium\data\Entity`.
    public function binding($name = null)
    {
        if (!$this->_binding) {
            return $this->_config['binding'](null, $name);
        }
        $binding = $this->_binding;
        $model = null;
        $key = $name;
        if (is_array($binding)) {
            switch (true) {
                case strpos($name, '.'):
                    list($model, $key) = explode('.', $name, 2);
                    $binding = isset($binding[$model]) ? $binding[$model] : reset($binding);
                    break;
                case isset($binding[$name]):
                    $binding = $binding[$name];
                    $key = null;
                    break;
                default:
                    $binding = reset($binding);
                    break;
            }
        }
        return $key ? $this->_config['binding']($binding, $key) : $binding;
    }