Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99342cc225 | ||
|
|
e8b6bb0ff9 | ||
|
|
b788835612 | ||
|
|
d24e18156f | ||
|
|
3dd594748c | ||
|
|
f620ae4b9c | ||
|
|
2b67d708ce | ||
|
|
bdc56f0239 | ||
|
|
6b68b0856c | ||
|
|
466aabedbd | ||
|
|
ef11b7dd2f | ||
|
|
f8cd022c4f | ||
|
|
bca8b11d67 | ||
|
|
db665c9f0f | ||
|
|
f62269629b | ||
|
|
2516472b3f | ||
|
|
828da38dcd | ||
|
|
acb21a9364 | ||
|
|
b5d6fdedb6 | ||
|
|
9ab4568241 | ||
|
|
575d891b64 |
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ language: php
|
|||||||
php:
|
php:
|
||||||
- 5.5
|
- 5.5
|
||||||
- 5.6
|
- 5.6
|
||||||
- hhvm
|
- 7.0
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
|
|||||||
+11
-9
@@ -3,8 +3,8 @@
|
|||||||
namespace Collective\Html;
|
namespace Collective\Html;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Illuminate\Routing\UrlGenerator;
|
use Illuminate\Contracts\Routing\UrlGenerator;
|
||||||
use Illuminate\Session\Store as Session;
|
use Illuminate\Session\SessionInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Traits\Macroable;
|
use Illuminate\Support\Traits\Macroable;
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ class FormBuilder
|
|||||||
/**
|
/**
|
||||||
* The URL generator instance.
|
* The URL generator instance.
|
||||||
*
|
*
|
||||||
* @var \Illuminate\Routing\UrlGenerator
|
* @var \Illuminate\Contracts\Routing\UrlGenerator
|
||||||
*/
|
*/
|
||||||
protected $url;
|
protected $url;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ class FormBuilder
|
|||||||
/**
|
/**
|
||||||
* The session store implementation.
|
* The session store implementation.
|
||||||
*
|
*
|
||||||
* @var \Illuminate\Session\Store
|
* @var \Illuminate\Session\SessionInterface
|
||||||
*/
|
*/
|
||||||
protected $session;
|
protected $session;
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ class FormBuilder
|
|||||||
/**
|
/**
|
||||||
* Create a new form builder instance.
|
* Create a new form builder instance.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Routing\UrlGenerator $url
|
* @param \Illuminate\Contracts\Routing\UrlGenerator $url
|
||||||
* @param \Collective\Html\HtmlBuilder $html
|
* @param \Collective\Html\HtmlBuilder $html
|
||||||
* @param string $csrfToken
|
* @param string $csrfToken
|
||||||
*
|
*
|
||||||
@@ -694,7 +694,9 @@ class FormBuilder
|
|||||||
protected function getSelectedValue($value, $selected)
|
protected function getSelectedValue($value, $selected)
|
||||||
{
|
{
|
||||||
if (is_array($selected)) {
|
if (is_array($selected)) {
|
||||||
return in_array($value, $selected) ? 'selected' : null;
|
return in_array($value, $selected, true) || in_array((string) $value, $selected, true)
|
||||||
|
? 'selected'
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((string) $value == (string) $selected) ? 'selected' : null;
|
return ((string) $value == (string) $selected) ? 'selected' : null;
|
||||||
@@ -1130,7 +1132,7 @@ class FormBuilder
|
|||||||
/**
|
/**
|
||||||
* Get the session store implementation.
|
* Get the session store implementation.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Session\Store $session
|
* @return \Illuminate\Session\SessionInterface $session
|
||||||
*/
|
*/
|
||||||
public function getSessionStore()
|
public function getSessionStore()
|
||||||
{
|
{
|
||||||
@@ -1140,11 +1142,11 @@ class FormBuilder
|
|||||||
/**
|
/**
|
||||||
* Set the session store implementation.
|
* Set the session store implementation.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Session\Store $session
|
* @param \Illuminate\Session\SessionInterface $session
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setSessionStore(Session $session)
|
public function setSessionStore(SessionInterface $session)
|
||||||
{
|
{
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
|
|
||||||
|
|||||||
+10
-4
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Collective\Html;
|
namespace Collective\Html;
|
||||||
|
|
||||||
use Illuminate\Routing\UrlGenerator;
|
use Illuminate\Contracts\Routing\UrlGenerator;
|
||||||
use Illuminate\Support\Traits\Macroable;
|
use Illuminate\Support\Traits\Macroable;
|
||||||
|
|
||||||
class HtmlBuilder
|
class HtmlBuilder
|
||||||
@@ -12,14 +12,14 @@ class HtmlBuilder
|
|||||||
/**
|
/**
|
||||||
* The URL generator instance.
|
* The URL generator instance.
|
||||||
*
|
*
|
||||||
* @var \Illuminate\Routing\UrlGenerator
|
* @var \Illuminate\Contracts\Routing\UrlGenerator
|
||||||
*/
|
*/
|
||||||
protected $url;
|
protected $url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new HTML builder instance.
|
* Create a new HTML builder instance.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Routing\UrlGenerator $url
|
* @param \Illuminate\Contracts\Routing\UrlGenerator $url
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -294,7 +294,13 @@ class HtmlBuilder
|
|||||||
$html = "<dl{$attributes}>";
|
$html = "<dl{$attributes}>";
|
||||||
|
|
||||||
foreach ($list as $key => $value) {
|
foreach ($list as $key => $value) {
|
||||||
$html .= "<dt>$key</dt><dd>$value</dd>";
|
$value = (array) $value;
|
||||||
|
|
||||||
|
$html .= "<dt>$key</dt>";
|
||||||
|
|
||||||
|
foreach ($value as $v_key => $v_value) {
|
||||||
|
$html .= "<dd>$v_value</dd>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= '</dl>';
|
$html .= '</dl>';
|
||||||
|
|||||||
@@ -267,6 +267,27 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
['name' => 'select-name']
|
['name' => 'select-name']
|
||||||
);
|
);
|
||||||
$this->assertEquals($select, '<select name="select-name" id="select-name-id"></select>');
|
$this->assertEquals($select, '<select name="select-name" id="select-name-id"></select>');
|
||||||
|
|
||||||
|
$select = $this->formBuilder->select(
|
||||||
|
'size',
|
||||||
|
[
|
||||||
|
'Large sizes' => [
|
||||||
|
'L' => 'Large',
|
||||||
|
'XL' => 'Extra Large',
|
||||||
|
],
|
||||||
|
'S' => 'Small',
|
||||||
|
],
|
||||||
|
null,
|
||||||
|
[
|
||||||
|
'class' => 'class-name',
|
||||||
|
'id' => 'select-id',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
$select,
|
||||||
|
'<select class="class-name" id="select-id" name="size"><optgroup label="Large sizes"><option value="L">Large</option><option value="XL">Extra Large</option></optgroup><option value="S">Small</option></select>'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormSelectRepopulation()
|
public function testFormSelectRepopulation()
|
||||||
@@ -468,6 +489,17 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('<input src="'.$url.'" type="image">', $image);
|
$this->assertEquals('<input src="'.$url.'" type="image">', $image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFormColor()
|
||||||
|
{
|
||||||
|
$form1 = $this->formBuilder->color('foo');
|
||||||
|
$form2 = $this->formBuilder->color('foo', '#ff0000');
|
||||||
|
$form3 = $this->formBuilder->color('foo', null, ['class' => 'span2']);
|
||||||
|
|
||||||
|
$this->assertEquals('<input name="foo" type="color">', $form1);
|
||||||
|
$this->assertEquals('<input name="foo" type="color" value="#ff0000">', $form2);
|
||||||
|
$this->assertEquals('<input class="span2" name="foo" type="color">', $form3);
|
||||||
|
}
|
||||||
|
|
||||||
protected function setModel(array $data, $object = true)
|
protected function setModel(array $data, $object = true)
|
||||||
{
|
{
|
||||||
if ($object) {
|
if ($object) {
|
||||||
|
|||||||
Reference in new issue
Block a user