-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix attribute types detected from validation rules
- Loading branch information
1 parent
129fe90
commit 281564e
Showing
3 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace yii1tech\model\typecast\test\data; | ||
|
||
use CFormModel; | ||
use yii1tech\model\typecast\AttributeTypecastBehavior; | ||
|
||
class FormWithTypecast extends CFormModel | ||
{ | ||
public $name; | ||
|
||
public $amount; | ||
|
||
public $price; | ||
|
||
public $isAccepted; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
['name', 'length', 'min' => 2], | ||
['amount', 'numerical', 'integerOnly' => true], | ||
['price', 'numerical', 'integerOnly' => false], | ||
['isAccepted', 'boolean'], | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function behaviors(): array | ||
{ | ||
return [ | ||
'typecastBehavior' => [ | ||
'class' => AttributeTypecastBehavior::class, | ||
'attributeTypes' => null, | ||
], | ||
]; | ||
} | ||
} |