Last active
February 13, 2020 13:36
-
-
Save ashour/d4ef9408f1f0076c4060317cf6a3afea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'FormControl.php'; | |
require_once dirname(__FILE__) . '/../functions.php'; | |
class Input extends FormControl | |
{ | |
public function __construct($name, $errors, $type = 'text') | |
{ | |
parent::__construct($name, $errors, $type); | |
} | |
public function render() | |
{ | |
$name = $this->name; | |
$label = __($this->name); | |
$type = $this->type; | |
$value = $_REQUEST[$this->name] ?? null; | |
$inputClasses = $this->inputClasses(); | |
$errorClasses = $this->errorClasses(); | |
$errorText = $this->errors[$this->name] ?? null; | |
return <<<HTML | |
<div class="field"> | |
<label class="label" for="{$name}">{$label}</label> | |
<div class="control"> | |
<input | |
id="{$name}" | |
name="{$name}" | |
type="{$type}" | |
value="{$value}" | |
class="{$inputClasses}" | |
> | |
</div> | |
<p class="{$errorClasses}">{$errorText}</p> | |
</div> | |
HTML; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment