diff --git a/composer.json b/composer.json index f348eb7..0b0b112 100755 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ ], "homepage": "https://github.com/phpzm/model", "license": "MIT", - "version": "1.0.0", + "version": "1.0.1", "type": "package", "authors": [ { diff --git a/src/DataMapper.php b/src/DataMapper.php index f86edac..08eaf70 100644 --- a/src/DataMapper.php +++ b/src/DataMapper.php @@ -5,6 +5,7 @@ use Simples\Data\Collection; use Simples\Data\Error\SimplesResourceError; use Simples\Data\Record; +use Simples\Helper\JSON; use Simples\Model\Error\SimplesActionError; use Simples\Model\Error\SimplesHookError; use Simples\Model\Resources\ModelParser; @@ -318,4 +319,33 @@ protected function getActionFields(string $action, bool $strict = true) } return $fields; } + + /** + * @return string + */ + public function getJSON() + { + $fields = []; + /** @var Field $field */ + foreach ($this->fields as $field) { + $fields[] = [ + 'field' => $field->getName(), + 'type' => $field->getType(), + 'label' => $field->option('label'), + 'grid' => true, + 'form' => ['create', 'show', 'edit'], + 'search' => true, + 'grids' => [ + 'width' => '' + ], + 'forms' => [ + 'component' => '', + 'width' => '', + 'disabled' => false, + 'order' => 0 + ] + ]; + } + return JSON::encode($fields); + } }