mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #11119 from creative-commoners/pulls/5/has-one-relation-field-interface
NEW HasOneRelationFieldInterface
This commit is contained in:
commit
05279f062c
11
src/Forms/HasOneRelationFieldInterface.php
Normal file
11
src/Forms/HasOneRelationFieldInterface.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
/**
|
||||
* Added to form fields whose values are the ID of a has_one relation
|
||||
* This is used in RequiredFields validation to check if the value is set
|
||||
*/
|
||||
interface HasOneRelationFieldInterface
|
||||
{
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\LinkField\Form\LinkField;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
|
||||
/**
|
||||
@ -117,7 +118,7 @@ class RequiredFields extends Validator
|
||||
}
|
||||
} else {
|
||||
$stringValue = (string) $value;
|
||||
if ($formField instanceof TreeDropdownField) {
|
||||
if (is_a($formField, HasOneRelationFieldInterface::class)) {
|
||||
// test for blank string as well as '0' because older versions of silverstripe/admin FormBuilder
|
||||
// forms created using redux-form would have a value of null for unsaved records
|
||||
// the null value will have been converted to '' by the time it gets to this point
|
||||
|
@ -55,7 +55,7 @@ use SilverStripe\ORM\Hierarchy\MarkedSet;
|
||||
* @see CheckboxSetField for multiple selections through checkboxes.
|
||||
* @see OptionsetField for single selections via radiobuttons.
|
||||
*/
|
||||
class TreeDropdownField extends FormField
|
||||
class TreeDropdownField extends FormField implements HasOneRelationFieldInterface
|
||||
{
|
||||
protected $schemaDataType = self::SCHEMA_DATA_TYPE_SINGLESELECT;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user