public function create($bindings = null, array $options = array())
{
$request = $this->_context ? $this->_context->request() : null;
$binding = is_array($bindings) ? reset($bindings) : $bindings;
$defaults = array('url' => $request ? $request->params : array(), 'type' => null, 'action' => null, 'method' => $binding ? $binding->exists() ? 'put' : 'post' : 'post');
list(, $options, $tpl) = $this->_defaults(__FUNCTION__, null, $options);
list($scope, $options) = $this->_options($defaults, $options);
$_binding =& $this->_binding;
$_options =& $this->_bindingOptions;
$params = compact('scope', 'options', 'bindings');
$extra = array('method' => __METHOD__) + compact('tpl', 'defaults');
$filter = function ($self, $params) use($extra, &$_binding, &$_options) {
$scope = $params['scope'];
$options = $params['options'];
$_binding = $params['bindings'];
$append = null;
$scope['method'] = strtolower($scope['method']);
if ($scope['type'] === 'file') {
if ($scope['method'] === 'get') {
$scope['method'] = 'post';
}
$options['enctype'] = 'multipart/form-data';
}
if (!($scope['method'] === 'get' || $scope['method'] === 'post')) {
$append = $self->hidden('_method', array('value' => strtoupper($scope['method'])));
$scope['method'] = 'post';
}
$url = $scope['action'] ? array('action' => $scope['action']) : $scope['url'];
$options['method'] = strtolower($scope['method']);
$args = array($extra['method'], $extra['tpl'], compact('url', 'options', 'append'));
$_options = $scope + $options;
return $self->invokeMethod('_render', $args);
};
return $this->_filter(__METHOD__, $params, $filter);
}