lithium\template\helper\Form::binding()

public method

Returns the entity that the Form helper is currently bound to.

Parameters

  • string $name

    If specified, match this field name against the list of bindings

  • string $key

    If $name specified, where to store relevant $_binding key

Returns

object

Returns an object, usually an instance of lithium\data\Entity.

Source

	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;
	}