Example #1
0
    public function render()
    {
        /** @var Command $class */
        $class = $this->commandState->commandClass;
        $action = $this->io->makeAnchor($class::createState());
        echo '<form method="post" action="' . $action . '">';
        foreach ($class::definition()->optionsArray() as $option) {
            $value = '';
            if (isset($this->commandState->{$option->name})) {
                $value = $this->commandState->{$option->name};
                if ($value instanceof Definition) {
                    $value = '';
                }
            }
            $labelCaption = $option->description ? $option->description : $option->name;
            $id = 'formItem' . ++self::$surrogateId;
            $name = $this->io->getRequestMapper()->getExportName($option);
            $this->io;
            echo <<<HTML
 <div class="form-group">
    <label for="{$id}">{$labelCaption}</label>
    <input class="form-control" id="{$id}" name="{$name}" placeholder="{$labelCaption}" value="{$value}">
 </div>
  
HTML;
        }
        $submitName = $class::definition()->getName();
        echo '<button type="submit" class="btn btn-default">' . $submitName . '</button>';
        echo '</form>';
    }