Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move field tests into a common TestCase class #6826

Draft
wants to merge 15 commits into
base: v5/develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/fields/structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
}

$column['type'] ??= $field['type'];
$column['label'] ??= $field['label'] ?? $name;
$column['label'] ??= $field['label'] ?? Str::ucfirst($name);
$column['label'] = I18n::translate($column['label'], $column['label']);

$columns[$name] = $column;
Expand Down
18 changes: 9 additions & 9 deletions src/Api/Controller/Changes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Kirby\Content\Lock;
use Kirby\Content\VersionId;
use Kirby\Filesystem\F;
use Kirby\Form\Form;
use Kirby\Form\Reform;

/**
* The Changes controller takes care of the request logic
Expand Down Expand Up @@ -90,13 +90,13 @@ public static function publish(ModelWithContent $model, array $input): array
*/
public static function save(ModelWithContent $model, array $input): array
{
// we need to run the input through the form
// class to get a set of storable field values
// that we can send to the content storage handler
$form = Form::for($model, [
'ignoreDisabled' => true,
'input' => $input,
]);
$form = new Reform(
model: $model,
language: 'current'
);

$form->fill($model);
$form->submit($input);

$changes = $model->version(VersionId::changes());
$latest = $model->version(VersionId::latest());
Expand All @@ -110,7 +110,7 @@ public static function save(ModelWithContent $model, array $input): array
$changes->save(
fields: [
...$latest->read(),
...$form->strings(),
...$form->toStoredValues(),
],
language: 'current'
);
Expand Down
5 changes: 3 additions & 2 deletions src/Cms/AppPlugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,9 @@ protected function extensionsFromSystem(): void
{
// Always start with fresh fields and sections
// from the core and add plugins on top of that
FormField::$types = [];
Section::$types = [];
FormField::$types = [];
FormField::$setups = [];
Section::$types = [];

// mixins
FormField::$mixins = $this->core->fieldMixins();
Expand Down
21 changes: 6 additions & 15 deletions src/Content/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace Kirby\Content;

use Kirby\Cms\File;
use Kirby\Cms\Language;
use Kirby\Cms\Languages;
use Kirby\Cms\ModelWithContent;
use Kirby\Cms\Page;
use Kirby\Cms\Site;
use Kirby\Exception\LogicException;
use Kirby\Exception\NotFoundException;
use Kirby\Form\Form;
use Kirby\Form\Reform;
use Kirby\Http\Uri;

/**
Expand Down Expand Up @@ -216,21 +215,13 @@ public function isIdentical(
$b['uuid']
);

$a = Form::for(
$form = new Reform(
model: $this->model,
props: [
'language' => $language->code(),
'values' => $a,
]
)->values();
language: $language,
);

$b = Form::for(
model: $this->model,
props: [
'language' => $language->code(),
'values' => $b
]
)->values();
$a = $form->fill($a)->toFormValues();
$b = $form->fill($b)->toFormValues();

ksort($a);
ksort($b);
Expand Down
Loading
Loading