Merge pull request #9931 from manuth/patch-4

Fix typos in 04_Data_Types_and_Casting.md
This commit is contained in:
Daniel Hensby 2021-05-14 09:47:54 +01:00 committed by GitHub
commit 2b0a7e21c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,7 +77,7 @@ class Car extends DataObject
When adding a new `$db` field to a DataObject you can specify a default value
to be applied to all existing records when the column is added in the database
for the first time. This will also be applied to any newly created objects
going forward. You do this be passing an argument for the default value in your
going forward. You do this by passing an argument for the default value in your
`$db` items.
For integer values, the default is the first parameter in the field specification.
@ -104,7 +104,7 @@ class Car extends DataObject
The Data Type does more than setup the correct database schema. They can also define methods and formatting helpers for
output. You can manually create instances of a Data Type and pass it through to the template.
If this case, we'll create a new method for our `Player` that returns the full name. By wrapping this in a [DBVarchar](api:SilverStripe\ORM\FieldType\DBVarchar)
In this case, we'll create a new method for our `Player` that returns the full name. By wrapping this in a [DBVarchar](api:SilverStripe\ORM\FieldType\DBVarchar)
object we can control the formatting and it allows us to call methods defined from `Varchar` as `LimitCharacters`.
**app/code/Player.php**
@ -134,7 +134,7 @@ echo $player->getName();
// returns "Sam Minnée";
echo $player->getName()->LimitCharacters(2);
// returns "Sa.."
// returns "Sa"
```
## Casting