Browse Source

Setup Develop

develop
sheychen 4 years ago
parent
commit
45c12ac189
  1. 4
      composer.json
  2. 6
      src/Element.php
  3. 4
      src/Form.php
  4. 2
      src/Input.php
  5. 2
      src/Select.php
  6. 2
      src/TextArea.php

4
composer.json

@ -8,11 +8,11 @@
}
],
"require": {
"krutush/template": "dev-master"
"krutush/template": "dev-develop"
},
"autoload": {
"psr-4": {
"Krutush\\Form\\": "src/"
}
}
}
}

6
src/Element.php

@ -21,12 +21,12 @@ class Element{
return $this;
}
public function value(string $value) : self{
public function value(string $value = null) : self{
$this->data['value'] = $value;
return $this;
}
public function get() : ?string{
public function get(){
return $this->data['value'];
}
@ -35,7 +35,7 @@ class Element{
return $this;
}
public function valid(mixed $data)/* :bool|string */{
public function valid($data)/* :bool|string */{
if((!isset($data) || empty($data)) && isset($this->data['required']) && $this->data['required'] == true)
return 'requis';

4
src/Form.php

@ -12,7 +12,7 @@ class Form {
private $errors = array();
private $set = false;
public function __construct(string $name, string $path, bool $extention = true, bool $folder = true){
public function __construct(string $name, string $path, string $extention = null, bool $folder = true){
$this->name = $name;
$tpl = new Html($path, $extention, $folder);
$tpl->set($name, $this)
@ -145,7 +145,7 @@ function SelectOther(source, other){
$this->elements[] = $thing;
}
public function get(string $name) : ?Element{
public function get(string $name) : Element{
foreach($this->elements as $element){
if($element->name() == $name)
return $element;

2
src/Input.php

@ -64,7 +64,7 @@ class Input extends Element{
return $this;
}
public function valid(mixde $data)/*: bool|string*/{
public function valid($data)/*: bool|string*/{
$parent = parent::valid($data);
if($parent !== true || !isset($data))

2
src/Select.php

@ -33,7 +33,7 @@ class Select extends Element{
}
public function valid(mixed $data)/*: bool|string*/{
public function valid($data)/*: bool|string*/{
$parent = parent::valid($data);
if($parent !== true || !isset($data))
return $parent;

2
src/TextArea.php

@ -3,7 +3,7 @@
namespace Krutush\Form;
class TextArea extends Element{
public function valid(mixed $data)/*: bool|string*/{
public function valid($data)/*: bool|string*/{
return parent::valid($data);
}

Loading…
Cancel
Save