Passed
Push — develop ( b546ed...ec145b )
by Felipe
08:20
created

FormTrait::getActionTableAndButtons()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 4
1
<?php
2
3
/**
4
 * PHPPgAdmin v6.0.0-beta.48
5
 */
6
7
namespace PHPPgAdmin\Traits;
8
9
/**
10
 * Common trait to print form parts that appear on different controller dialogs.
11
 */
12
trait FormTrait
13
{
14
    public $misc;
15
16
    /**
17
     * Prints inputs for action, table and submit/cancel buttons.
18
     *
19
     * @param string $action value for action input
20
     * @param string $table  value for table input
21
     * @param string $add    text for add button
22
     * @param string $cancel text for cancel button
23
     */
24
    public function getActionTableAndButtons($action, $table, $add, $cancel)
25
    {
26
        $content = $this->misc->form;
27
        $content .= sprintf('<input type="hidden" name="action" value="%s" />%s', $action, "\n");
28
        $content .= sprintf('<input type="hidden" name="table" value="%s" />%s', $table, "\n");
29
        $content .= sprintf('<input type="submit" value="%s" />%s', $add, "\n");
30
        $content .= sprintf('<input type="submit" name="cancel" value="%s" />', $cancel);
31
32
        return $content;
33
    }
34
}
35