public function dependentOnObject(callable $dependentStageDefineCallback, array $fieldNamesDefinedInStage = [])
    {
        $requiredParameters = Reflection::fromCallable($dependentStageDefineCallback)->getNumberOfRequiredParameters();

        if ($this->isCreateForm()) {
            if ($requiredParameters === 1) {
                $dependentStageDefineCallback($this);
            }

            return;
        }

        $this->dependentOn([], function (CrudFormDefinition $definition, array $previousData, $object) use ($dependentStageDefineCallback) {
            $dependentStageDefineCallback($definition, $object);
        }, $fieldNamesDefinedInStage);
    }
public function dependentOnObject(callable $dependentStageDefineCallback, array $fieldNamesDefinedInStage = [])
    {
        $requiredParameters = Reflection::fromCallable($dependentStageDefineCallback)->getNumberOfRequiredParameters();

        if ($this->isCreateForm()) {
            if ($requiredParameters === 1) {
                $dependentStageDefineCallback($this);
            }

            return;
        }

        $this->dependentOn([], function (CrudFormDefinition $definition, array $previousData, $object) use ($dependentStageDefineCallback) {
            $dependentStageDefineCallback($definition, $object);
        }, $fieldNamesDefinedInStage);
    }
public function dependentOnObject ( callable $ dependentStageDefineCallback , array $ fieldNamesDefinedInStage = [ ] ) { $ requiredParameters = Reflection :: fromCallable ( $ dependentStageDefineCallback ) -> getNumberOfRequiredParameters ( ) ; if ( $ this -> isCreateForm ( ) ) { if ( $ requiredParameters === 1 ) { $ dependentStageDefineCallback ( $ this ) ; } return ; } $ this -> dependentOn ( [ ] , function ( CrudFormDefinition $ definition , array $ previousData , $ object ) use ( $ dependentStageDefineCallback ) { $ dependentStageDefineCallback ( $ definition , $ object ) ; } , $ fieldNamesDefinedInStage ) ; }
Defines a section of the form that is dependent on the object which the form is bound to.

The supplied callback will be passed the object instance as the second parameter.

NOTE: This will ignore the fields defined in this section if it is a create form and
the object field is a required parameter, if you want to support this in create forms,
default the object parameter to null and handle this case.

Example:
<code>
$form->dependentOnObject(function (CrudFormDefinition $form, Person $person = null) {
if ($person === null) { // Equivalent to $form->isCreateForm()
// ...
} elseif ($person->isAdmin()) {
// ...
} else {
// ...
}
});
</code>

@param callable $dependentStageDefineCallback
@param string[] $fieldNamesDefinedInStage

@return void
@throws InvalidOperationException
Defines a section of the form that is dependent on the object which the form is bound to .