Skip to content

Commit 44f9ade

Browse files
committed
Container: addImage() renamed to addImageButton()
1 parent 2d0f255 commit 44f9ade

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

src/Forms/Container.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,19 @@ public function addButton(string $name, $caption = null): Controls\Button
435435
* @param string $src URI of the image
436436
* @param string $alt alternate text for the image
437437
*/
438-
public function addImage(string $name, string $src = null, string $alt = null): Controls\ImageButton
438+
public function addImageButton(string $name, string $src = null, string $alt = null): Controls\ImageButton
439439
{
440440
return $this[$name] = new Controls\ImageButton($src, $alt);
441441
}
442442

443443

444+
/** @deprecated use addImageButton() */
445+
public function addImage(): Controls\ImageButton
446+
{
447+
return $this->addImageButton(...func_get_args());
448+
}
449+
450+
444451
/**
445452
* Adds naming container to the form.
446453
* @param string|int $name

tests/Forms/Controls.ImageButton.loadData.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ test('', function () {
2828
];
2929

3030
$form = new Form;
31-
$input = $form->addImage('image');
31+
$input = $form->addImageButton('image');
3232
Assert::true($input->isFilled());
3333
Assert::same([1, 2], $input->getValue());
3434

35-
$input = $form->addContainer('container')->addImage('image');
35+
$input = $form->addContainer('container')->addImageButton('image');
3636
Assert::same([3, 4], $form['container']['image']->getValue());
3737
});
3838

3939

4040
test('missing data', function () {
4141
$form = new Form;
42-
$input = $form->addImage('missing');
42+
$input = $form->addImageButton('missing');
4343
Assert::false($input->isFilled());
4444
Assert::null($input->getValue());
4545
});
@@ -52,11 +52,11 @@ test('malformed data', function () {
5252
];
5353

5454
$form = new Form;
55-
$input = $form->addImage('malformed1');
55+
$input = $form->addImageButton('malformed1');
5656
Assert::true($input->isFilled());
5757
Assert::same([1, 0], $input->getValue());
5858

59-
$input = $form->addImage('malformed2');
59+
$input = $form->addImageButton('malformed2');
6060
Assert::false($input->isFilled());
6161
Assert::null($input->getValue());
6262
});

tests/Forms/Controls.ImageButton.render.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Translator implements Nette\Localization\ITranslator
2525

2626
test('', function () {
2727
$form = new Form;
28-
$input = $form->addImage('button', 'image.gif');
28+
$input = $form->addImageButton('button', 'image.gif');
2929

3030
Assert::null($input->getLabel());
3131
Assert::type(Html::class, $input->getControl());
@@ -35,7 +35,7 @@ test('', function () {
3535

3636
test('translator', function () {
3737
$form = new Form;
38-
$input = $form->addImage('button', 'image.gif');
38+
$input = $form->addImageButton('button', 'image.gif');
3939
$input->setTranslator(new Translator);
4040

4141
Assert::same('<input type="image" name="button[]" src="image.gif">', (string) $input->getControl());
@@ -44,7 +44,7 @@ test('translator', function () {
4444

4545
test('no validation rules', function () {
4646
$form = new Form;
47-
$input = $form->addImage('button', 'image.gif')->setRequired('required');
47+
$input = $form->addImageButton('button', 'image.gif')->setRequired('required');
4848

4949
Assert::same('<input type="image" name="button[]" src="image.gif">', (string) $input->getControl());
5050
});
@@ -53,15 +53,15 @@ test('no validation rules', function () {
5353
test('container', function () {
5454
$form = new Form;
5555
$container = $form->addContainer('container');
56-
$input = $container->addImage('button', 'image.gif');
56+
$input = $container->addImageButton('button', 'image.gif');
5757

5858
Assert::same('<input type="image" name="container[button][]" src="image.gif">', (string) $input->getControl());
5959
});
6060

6161

6262
test('rendering options', function () {
6363
$form = new Form;
64-
$input = $form->addImage('button');
64+
$input = $form->addImageButton('button');
6565

6666
Assert::same('button', $input->getOption('type'));
6767

tests/Forms/Forms.submittedBy.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ test('', function () {
3838
$_POST = [Form::TRACKER_ID => $name, 'send2' => ['x' => '1', 'y' => '1']];
3939

4040
$form = new Form($name);
41-
$btn1 = $form->addImage('send1');
42-
$btn2 = $form->addImage('send2');
43-
$btn3 = $form->addImage('send3');
41+
$btn1 = $form->addImageButton('send1');
42+
$btn2 = $form->addImageButton('send2');
43+
$btn3 = $form->addImageButton('send3');
4444

4545
Assert::true($form->isSuccess());
4646
Assert::same($btn2, $form->isSubmitted());

0 commit comments

Comments
 (0)