Compare commits

...
16 Commits
Author SHA1 Message Date
Matt Lantz f620ae4b9c Merge pull request #127 from lanort/patch-1
Update FormBuilder.php: fix to get selected value with 0 as index
2017-05-20 13:43:22 -04:00
Tom Shafer 2b67d708ce Merge pull request #160 from neoxia/5.1
Add PHP 7 to travis configuration
2016-03-02 21:02:33 -07:00
Tom Shafer bdc56f0239 Merge pull request #128 from EspadaV8/feature/add-missing-form-select-test
Add test for select optgroups
2016-03-02 21:01:11 -07:00
Alexandre Butynski 6b68b0856c Add PHP 7 to travis configuration 2016-02-10 13:45:37 +01:00
Andrew Smith 466aabedbd Add test for select optgroups 2015-12-15 16:53:33 +10:00
lanort ef11b7dd2f Update FormBuilder.php: fix to get selected value with 0 as index
`getSelectedValue` returns always true if it receives a value (from an select input) of 0. To avoid that the strict parameter has to be set to true.

This is because the following code does not work as might expected:

    <?php
    // check if 0 is in the array [1 => "c16"]
    var_dump(in_array(0, [1=>"c16"])); // returns true
2015-12-14 23:33:12 +01:00
Adam Engebretson f8cd022c4f Merge pull request #120 from mul14/add-test-for-input-color-type
Add test for input color type
2015-11-28 02:36:08 -06:00
Mulia Arifandi Nasution bca8b11d67 Fix Style-CI 2015-11-28 15:34:33 +07:00
Mulia Arifandi Nasution db665c9f0f Add test for input color type 2015-11-28 15:32:53 +07:00
Adam Engebretson f62269629b Merge pull request #96 from patrickbrouwers/patch-1
HtmlBuilder shouldn't depend on concrete implementation
2015-11-28 02:27:09 -06:00
Adam Engebretson 2516472b3f Merge pull request #97 from patrickbrouwers/patch-2
Don't depend on concretes in FormBuilder
2015-11-28 02:26:44 -06:00
Adam Engebretson 828da38dcd Merge pull request #100 from jackmcdade/5.1
dl() now supports multiple descriptions per term
2015-11-28 02:26:21 -06:00
Jack McDade acb21a9364 correct code formatting 2015-10-23 17:47:44 -04:00
Jack McDade b5d6fdedb6 dl() now supports multiple descriptions per term 2015-10-23 17:45:01 -04:00
Patrick Brouwers 9ab4568241 Don't depend on concretes in FormBuilder 2015-10-08 10:08:07 +02:00
Patrick Brouwers 575d891b64 HtmlBuilder shouldn't depend on concrete implementation 2015-10-08 09:56:16 +02:00
4 changed files with 52 additions and 13 deletions

No files matched your search

+1
View File
@@ -3,6 +3,7 @@ language: php
php:
- 5.5
- 5.6
- 7.0
- hhvm
sudo: false
+9 -9
View File
@@ -3,8 +3,8 @@
namespace Collective\Html;
use DateTime;
use Illuminate\Routing\UrlGenerator;
use Illuminate\Session\Store as Session;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Session\SessionInterface;
use Illuminate\Support\Collection;
use Illuminate\Support\Traits\Macroable;
@@ -22,7 +22,7 @@ class FormBuilder
/**
* The URL generator instance.
*
* @var \Illuminate\Routing\UrlGenerator
* @var \Illuminate\Contracts\Routing\UrlGenerator
*/
protected $url;
@@ -36,7 +36,7 @@ class FormBuilder
/**
* The session store implementation.
*
* @var \Illuminate\Session\Store
* @var \Illuminate\Session\SessionInterface
*/
protected $session;
@@ -78,7 +78,7 @@ class FormBuilder
/**
* Create a new form builder instance.
*
* @param \Illuminate\Routing\UrlGenerator $url
* @param \Illuminate\Contracts\Routing\UrlGenerator $url
* @param \Collective\Html\HtmlBuilder $html
* @param string $csrfToken
*
@@ -694,7 +694,7 @@ class FormBuilder
protected function getSelectedValue($value, $selected)
{
if (is_array($selected)) {
return in_array($value, $selected) ? 'selected' : null;
return in_array($value, $selected, true) ? 'selected' : null;
}
return ((string) $value == (string) $selected) ? 'selected' : null;
@@ -1130,7 +1130,7 @@ class FormBuilder
/**
* Get the session store implementation.
*
* @return \Illuminate\Session\Store $session
* @return \Illuminate\Session\SessionInterface $session
*/
public function getSessionStore()
{
@@ -1140,11 +1140,11 @@ class FormBuilder
/**
* Set the session store implementation.
*
* @param \Illuminate\Session\Store $session
* @param \Illuminate\Session\SessionInterface $session
*
* @return $this
*/
public function setSessionStore(Session $session)
public function setSessionStore(SessionInterface $session)
{
$this->session = $session;
+10 -4
View File
@@ -2,7 +2,7 @@
namespace Collective\Html;
use Illuminate\Routing\UrlGenerator;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Support\Traits\Macroable;
class HtmlBuilder
@@ -12,14 +12,14 @@ class HtmlBuilder
/**
* The URL generator instance.
*
* @var \Illuminate\Routing\UrlGenerator
* @var \Illuminate\Contracts\Routing\UrlGenerator
*/
protected $url;
/**
* Create a new HTML builder instance.
*
* @param \Illuminate\Routing\UrlGenerator $url
* @param \Illuminate\Contracts\Routing\UrlGenerator $url
*
* @return void
*/
@@ -294,7 +294,13 @@ class HtmlBuilder
$html = "<dl{$attributes}>";
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>';
+32
View File
@@ -267,6 +267,27 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
['name' => 'select-name']
);
$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()
@@ -468,6 +489,17 @@ class FormBuilderTest extends PHPUnit_Framework_TestCase
$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)
{
if ($object) {