Skip to content

Commit a43e701

Browse files
committed
update
1 parent 2169618 commit a43e701

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/Elements.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public static function select(string $name = '', array $options = []): Select
167167
}
168168

169169
/**
170-
* @param array<string|int, string> $options
170+
* @param array<string> $options
171171
*/
172172
public static function selectOrType(string $name = '', array $options = [], string $typeCaption = ''): SelectOrType
173173
{

src/SelectOrType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class SelectOrType implements Control
1010
use HtmlElement;
1111

1212
protected string $name = '';
13-
/** @var array<string|int,string> $options */
13+
/** @var array<string,string> $options */
1414
protected array $options = [];
15-
/** @var array<string|int,string> $originalOptions */
15+
/** @var array<string,string> $originalOptions */
1616
protected array $originalOptions = [];
1717
protected string $value = '';
1818
protected string $placeholder = '';
@@ -73,11 +73,11 @@ public function autocomplete(string $value): self
7373
}
7474

7575
/**
76-
* @param array<string|int,string> $options
76+
* @param array<string> $options
7777
*/
7878
public function options(array $options): self
7979
{
80-
$this->options = $options;
80+
$this->options = array_combine($options, $options);
8181
if (!isset($this->options[''])) {
8282
$this->options = ['' => '...'] + $this->options; // Add empty option if not present
8383
}

tests/Forms/DifferentFormTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class DifferentFormTest extends TestCase
1313
private function createForm(string $style): Form
1414
{
1515
$sources = [
16-
'ad' => 'Ad',
17-
'blog' => 'Blog',
18-
'magazine' => 'Magazine',
19-
'newspaper' => 'Newspaper',
16+
'Ad',
17+
'Blog',
18+
'Magazine',
19+
'Newspaper',
2020
];
2121
E::$style = $style;
2222
return E::form([
@@ -32,10 +32,10 @@ public function testRenderForm(): void
3232
' <label for="source">How did you find us?</label>',
3333
' <select id="source" name="source" onchange="var last=this.options[this.options.length-1]; var hasPrevious=last.previousSibling.nodeName==\'HR\'; if (this.options.length-1==this.selectedIndex) { var str=prompt(last.text,last.previousSibling.text); if (str) { if (hasPrevious) { opt=document.createElement(\'option\'); this.insertBefore(opt, last); } else { opt=last.previousSibling; } opt.value=opt.text=str; this.selectedIndex-=1; } else { this.selectedIndex=this.dataset.lastIndex; } } this.dataset.lastIndex=this.selectedIndex;">',
3434
' <option value="" selected="selected">...</option>',
35-
' <option value="ad">Ad</option>',
36-
' <option value="blog">Blog</option>',
37-
' <option value="magazine">Magazine</option>',
38-
' <option value="newspaper">Newspaper</option>',
35+
' <option value="Ad">Ad</option>',
36+
' <option value="Blog">Blog</option>',
37+
' <option value="Magazine">Magazine</option>',
38+
' <option value="Newspaper">Newspaper</option>',
3939
' <hr/>',
4040
' <option value="!type!">Different ...</option>',
4141
' </select>',
@@ -53,10 +53,10 @@ public function testRenderBulma(): void
5353
' <div class="select">',
5454
' <select id="source" name="source" onchange="var last=this.options[this.options.length-1]; var hasPrevious=last.previousSibling.nodeName==\'HR\'; if (this.options.length-1==this.selectedIndex) { var str=prompt(last.text,last.previousSibling.text); if (str) { if (hasPrevious) { opt=document.createElement(\'option\'); this.insertBefore(opt, last); } else { opt=last.previousSibling; } opt.value=opt.text=str; this.selectedIndex-=1; } else { this.selectedIndex=this.dataset.lastIndex; } } this.dataset.lastIndex=this.selectedIndex;">',
5555
' <option value="" selected="selected">...</option>',
56-
' <option value="ad">Ad</option>',
57-
' <option value="blog">Blog</option>',
58-
' <option value="magazine">Magazine</option>',
59-
' <option value="newspaper">Newspaper</option>',
56+
' <option value="Ad">Ad</option>',
57+
' <option value="Blog">Blog</option>',
58+
' <option value="Magazine">Magazine</option>',
59+
' <option value="Newspaper">Newspaper</option>',
6060
' <hr/>',
6161
' <option value="!type!">Different ...</option>',
6262
' </select>',

0 commit comments

Comments
 (0)