Skip to content

Commit

Permalink
ENH Update scaffolded search fields to be more sensible
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Feb 18, 2025
1 parent c0880fa commit d047b6c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/ORM/FieldType/DBCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use SilverStripe\Forms\CurrencyField;
use SilverStripe\Forms\FormField;
use SilverStripe\Forms\NumericField;
use SilverStripe\Model\ModelData;

/**
Expand Down Expand Up @@ -68,4 +69,9 @@ public function scaffoldFormField(?string $title = null, array $params = []): ?F
{
return CurrencyField::create($this->getName(), $title);
}

public function scaffoldSearchField(?string $title = null): ?FormField
{
return NumericField::create($this->getName(), $title);
}
}
6 changes: 6 additions & 0 deletions src/ORM/FieldType/DBEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\ORM\FieldType\DBVarchar;
use SilverStripe\Core\Validation\FieldValidation\EmailFieldValidator;
use SilverStripe\Forms\FormField;
use SilverStripe\Forms\TextField;

class DBEmail extends DBVarchar
{
Expand All @@ -19,4 +20,9 @@ public function scaffoldFormField(?string $title = null, array $params = []): ?F
$field->setMaxLength($this->getSize());
return $field;
}

public function scaffoldSearchField(?string $title = null): ?FormField
{
return TextField::create($this->getName(), $title);
}
}
2 changes: 1 addition & 1 deletion src/ORM/FieldType/DBHTMLText.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function scaffoldFormField(?string $title = null, array $params = []): ?F

public function scaffoldSearchField(?string $title = null): ?FormField
{
return new TextField($this->name, $title);
return TextField::create($this->name, $title);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/ORM/FieldType/DBUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use SilverStripe\ORM\FieldType\DBVarchar;
use SilverStripe\Core\Validation\FieldValidation\UrlFieldValidator;
use SilverStripe\Forms\FormField;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\UrlField;

class DBUrl extends DBVarchar
Expand All @@ -19,4 +20,9 @@ public function scaffoldFormField(?string $title = null, array $params = []): ?F
$field->setMaxLength($this->getSize());
return $field;
}

public function scaffoldSearchField(?string $title = null): ?FormField
{
return TextField::create($this->getName(), $title);
}
}

0 comments on commit d047b6c

Please sign in to comment.