update:更新form功能

This commit is contained in:
JaguarJack
2021-03-29 19:51:41 +08:00
parent 114387d030
commit 2f25a0892e
4 changed files with 69 additions and 26 deletions

View File

@@ -58,7 +58,6 @@ abstract class Form
use UploadFactoryTrait;
use ValidateFactoryTrait;
use GroupFactoryTrait;
use FormOptions;
use FormValidates;
protected $primaryKeyField = 'id';
@@ -121,9 +120,13 @@ abstract class Form
*/
protected function getFields(): array
{
return array_merge($this->fields(), [
self::hidden($this->primaryKeyField, 0)
]);
if ($this->primaryKeyField) {
return array_merge($this->fields(), [
self::hidden($this->primaryKeyField, 0)
]);
}
return $this->fields();
}
/**
@@ -135,10 +138,6 @@ abstract class Form
*/
public function rule(array $rules): array
{
if ($this->primaryKeyField) {
array_push($rules, self::hidden($this->primaryKeyField, 0));
}
try{
return Elm::createForm('', $rules)->formRule();
} catch (FormBuilderException $e) {
@@ -251,4 +250,15 @@ abstract class Form
->data(['none' => ''])
->headers(self::authorization());
}
/**
* options
*
* @time 2021年03月24日
* @return FormOptions
*/
public static function options(): FormOptions
{
return new FormOptions();
}
}