Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixing double use of library key in Form::create(). #387

Closed
wants to merge 1 commit into from

2 participants

@Ciaro

This will fix issue #374 and #321 (duplicate).

@gwoo gwoo commented on the diff
tests/cases/template/helper/FormTest.php
@@ -771,6 +771,30 @@ public function testFormCreateWithMoreParams() {
)));
}
+ public function testFormCreateInSubmodule() {
+ Router::reset();
+ Router::connect('/users', array('controller' => 'submodule.Users'));
+ Router::connect('/users/{:action}', array('controller' => 'submodule.Users'));
+
+ $request = new Request();
+ $request->params = array(
+ 'library' => 'submodule',
+ 'controller' => 'submodule.Users',
@gwoo Owner
gwoo added a note

Why are you using submodule twice?

@Ciaro
Ciaro added a note

Cause that's how the request object looks like when you use Form::create() in a submodule :(

@gwoo Owner
gwoo added a note

OK, then the problem is most likely somewhere else. What do your routes look like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Ciaro

Actually, just like this:

Router::connect('/users', array('controller' => 'submodule.Users'));
Router::connect('/users/{:action}', array('controller' => 'submodule.Users'));

There is more info in the tickets #374 and #321. Thank you, @gwoo!

@Ciaro

The underlying functionality of Router::match() seemed to be the issue. I'm closing this request in favor of one with a failing test (proving the bug) + a fix for it.

@Ciaro Ciaro closed this
@titus88 titus88 referenced this pull request from a commit
@gwoo gwoo BREAK: Fixes #387 on dev.lithify.me. Changes `net\http\Request::$para…
…ms` to `query`. See change in test cases.
f453b39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2012
  1. @Ciaro
This page is out of date. Refresh to see the latest.
View
5 template/helper/Form.php
@@ -294,6 +294,11 @@ public function create($binding = null, array $options = array()) {
$url = $scope['action'] ? array('action' => $scope['action']) : $scope['url'];
$options['method'] = strtolower($scope['method']);
+
+ if (is_array($url) && isset($url['library'])) {
+ unset($url['library']);
+ }
+
$args = array($extra['method'], $extra['tpl'], compact('url', 'options', 'append'));
$_options = $scope + $options;
View
24 tests/cases/template/helper/FormTest.php
@@ -771,6 +771,30 @@ public function testFormCreateWithMoreParams() {
)));
}
+ public function testFormCreateInSubmodule() {
+ Router::reset();
+ Router::connect('/users', array('controller' => 'submodule.Users'));
+ Router::connect('/users/{:action}', array('controller' => 'submodule.Users'));
+
+ $request = new Request();
+ $request->params = array(
+ 'library' => 'submodule',
+ 'controller' => 'submodule.Users',
@gwoo Owner
gwoo added a note

Why are you using submodule twice?

@Ciaro
Ciaro added a note

Cause that's how the request object looks like when you use Form::create() in a submodule :(

@gwoo Owner
gwoo added a note

OK, then the problem is most likely somewhere else. What do your routes look like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ 'action' => 'index'
+ );
+ $request->persist = array('controller');
+
+ $context = new MockFormRenderer(compact('request'));
+ $form = new Form(compact('context'));
+
+ $result = $form->create();
+
+ $this->assertTags($result, array('form' => array(
+ 'action' => "/users",
+ 'method' => 'post'
+ )));
+ }
+
public function testFormCreateWithMoreParamsButSpecifiedAction() {
$request = new Request();
$request->params = array('controller' => 'mock', 'action' => 'test', 'args' => array('1'));
View
2  tests/cases/template/helper/HtmlTest.php
@@ -280,7 +280,7 @@ public function testScriptLinking() {
$expected = '<script type="text/javascript" src="http://example.com/jquery.js"></script>';
$this->assertEqual($result, $expected);
- $result = $this->html->script('//example.com/jquery.js');
+ $result = $this->html->script('//example.com/jquery.js');
$expected = '<script type="text/javascript" src="//example.com/jquery.js"></script>';
$this->assertEqual($result, $expected);
Something went wrong with that request. Please try again.