Browse Source

Setup Develop

develop
sheychen 1 year ago
parent
commit
45c12ac189
6 changed files with 10 additions and 10 deletions
  1. 2
    2
      composer.json
  2. 3
    3
      src/Element.php
  3. 2
    2
      src/Form.php
  4. 1
    1
      src/Input.php
  5. 1
    1
      src/Select.php
  6. 1
    1
      src/TextArea.php

+ 2
- 2
composer.json View File

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

+ 3
- 3
src/Element.php View File

@@ -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';


+ 2
- 2
src/Form.php View File

@@ -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;

+ 1
- 1
src/Input.php View File

@@ -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))

+ 1
- 1
src/Select.php View File

@@ -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;

+ 1
- 1
src/TextArea.php View File

@@ -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