无法理解
Error: java.lang.NumberFormatException: For input string: "45.8"
Parsed as Double: 45.8
Error: java.lang.NumberFormatException: For input string: "45.8"
Parsed as BigDecimal: 45.8
如果我删除表单的结构并检查debug:autowiring,我会得到:
Severity Code Description Project File Line Suppression State
Error The "Javac" task failed unexpectedly.
System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
at System.IO.LongPathHelper.Normalize(String path, UInt32 maxPathLength, Boolean checkInvalidCharacters, Boolean expandShortPaths)
at System.IO.Path.NewNormalizePath(String path, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.FileInfo.Init(String fileName, Boolean checkHost)
at System.IO.FileInfo..ctor(String fileName)
at Xamarin.Android.Tasks.ZipArchiveEx.AddFiles(String folder, String folderInArchive)
at Xamarin.Android.Tasks.ZipArchiveEx.AddDirectory(String folder, String folderInArchive)
at Xamarin.Android.Tasks.Javac.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() XamarinApp1.Android
不确定如何在Cannot autowire service "App\Form\SomeFormType": argument "$parameterBag" of method "__construct()" references interface "Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface" but no such service exists. Did you create a class that implements this interface?
中手动解析除注入参数之外的内容
答案 0 :(得分:1)
您是否已在config/services.yaml
文件中正确配置了自动接线?
最重要的部分:
# config/services.yaml
services:
_defaults:
autowire: true // <--- it should be true
autoconfigure: true
public: false
您还可以提供自动连线单一服务的功能:
Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface:
autowire: true
无论如何,我认为您不应该将整个ParameterBag传递到表单中。您应该在创建表单时传递所需的值。
我敢打赌,你正在做类似的事情:
$form = $this->createForm(App\Form\SomeFormType::class, $data, [
'key' => 'value', //it should be also some options builder class
]);
您可以在第3个参数中传递一些选项,并且可以在SomeFormType中访问它们:
class SomeFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
dump($options); // will output parameters from createForm (['key' => 'value'])
}
// ...
手册