src/HTMLForm/FormModelLogin.php
<?php
namespace Anax\HTMLForm;
use Psr\Container\ContainerInterface;
/**
* Example of FormModel implementation.
*/
class FormModelLogin extends FormModel
{
/**
* Constructor injects with DI container.
*
* @param Anax\DI\DIInterface $di a service container
*/
public function __construct(ContainerInterface $di)
{
parent::__construct($di);
$this->form->create(
[
"id" => __CLASS__,
"legend" => "User Login"
],
[
"user" => [
"type" => "text",
//"description" => "Here you can place a description.",
//"placeholder" => "Here is a placeholder",
],
"password" => [
"type" => "password",
//"description" => "Here you can place a description.",
//"placeholder" => "Here is a placeholder",
],
"submit" => [
"type" => "submit",
"value" => "Login",
"callback" => [$this, "callbackSubmit"]
],
]
);
}
/**
* Callback for submit-button which should return true if it could
* carry out its work and false if something failed.
*
* @return boolean true if okey, false if something went wrong.
*/
public function callbackSubmit()
{
$this->form->addOutput(
"Trying to login as: "
. $this->form->value("user")
. "<br>Password is kept a secret..."
//. $this->form->value("password")
);
// Remember values during resubmit
$this->form->rememberValues();
return true;
}
}