title: Passing parent entity Id into child form
body: <p>Good day,
  I got entity ScheduledCommand into relation OneToMany to ScheduledCommandLimitRange</p>
  <pre><code>/**
   * @ORM\MappedSuperclass (repositoryClass=&quot;Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandRepository&quot;)
   * @ORM\Table(&quot;scheduled_command&quot;)
   */
  class ScheduledCommand implements ScheduledCommandInterface
  {
      /**
       * @var int|null
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type=&quot;integer&quot;)
       */
      private $id;
  
      /**
       * @var string
       * @ORM\Column(type=&quot;string&quot;)
       */
      private $name = '';
  
      /**
       * @var string
       * @ORM\Column(type=&quot;string&quot;)
       */
      private $command = '';
  
      /**
       * @var int
       * @ORM\Column(type=&quot;integer&quot;)
       */
      private $priority = 0;
  
      /**
       * @ORM\OneToMany(targetEntity=&quot;ScheduledCommandLimitRange&quot;, mappedBy=&quot;scheduledCommand&quot;, orphanRemoval=true, cascade={&quot;persist&quot;})
       * @ORM\JoinColumn(nullable=false)
       */
      private $commandLimitRanges;
  
      public function getId(): ?int
      {
          return $this-&gt;id;
      }
  
      public function getName(): string
      {
          return $this-&gt;name;
      }
  
      public function setName(string $name): ScheduledCommandInterface
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      public function getCommand(): string
      {
          return $this-&gt;command;
      }
  
      public function setCommand(string $command): ScheduledCommandInterface
      {
          $this-&gt;command = $command;
  
          return $this;
      }
  
      public function getPriority(): int
      {
          return $this-&gt;priority;
      }
  
      public function setPriority(int $priority): ScheduledCommandInterface
      {
          $this-&gt;priority = $priority;
  
          return $this;
      }
  
      public function getCommandLimitRanges(): ?Collection
      {
          return $this-&gt;commandLimitRanges;
      }
  
      public function setCommandLimitRanges(Collection $commandLimitRange): ?Collection
      {
          $this-&gt;commandLimitRanges = $commandLimitRange;
          return $this-&gt;commandLimitRanges;
      }
  }
  </code></pre>
  <p>This is my ManyToOne class:</p>
  <pre><code>/**
   * @ORM\Entity(repositoryClass=&quot;Synolia\SyliusSchedulerCommandPlugin\Repository\ScheduledCommandLimitRangeRepository&quot;)
   * @ORM\Table(name=&quot;scheduled_command_limit_range&quot;)
   */
  class ScheduledCommandLimitRange implements ScheduledCommandLimitRangeInterface
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type=&quot;integer&quot;)
       */
      private $id;
  
      /**
       * @var \DateTime|null
       * @ORM\Column(type=&quot;datetime&quot;, nullable=true)
       */
      private $timeFrom;
  
      /**
       * @var \DateTime|null
       * @ORM\Column(type=&quot;datetime&quot;, nullable=true)
       */
      private $timeTo;
  
      /**
       * @ORM\ManyToOne(targetEntity=&quot;ScheduledCommand&quot;, inversedBy=&quot;commandLimitRanges&quot;)
       */
      private $scheduledCommand;
  
      public function getId(): ?int
      {
          return $this-&gt;id;
      }
  
      public function getTimeFrom(): ?\DateTime
      {
          return $this-&gt;timeFrom;
      }
  
      public function setTimeFrom(?\DateTime $timeFrom): ScheduledCommandLimitRangeInterface
      {
          $this-&gt;timeFrom = $timeFrom;
  
          return $this;
      }
  
      public function getTimeTo(): ?\DateTime
      {
          return $this-&gt;timeTo;
      }
  
      public function setTimeTo(?\DateTime $timeTo): ScheduledCommandLimitRangeInterface
      {
          $this-&gt;timeTo = $timeTo;
  
          return $this;
      }
  
      public function getScheduledCommand(): ?ScheduledCommand
      {
          return $this-&gt;scheduledCommand;
      }
      public function setScheduledCommand(ScheduledCommand $scheduledCommand): ?ScheduledCommand
      {
          $this-&gt;scheduledCommand = $scheduledCommand;
  
          return $this;
      }
  </code></pre>
  <p>I got ScheduledCommandType that is has CollectionType in one field, that has entry_type of CommandLimitType.</p>
  <pre><code>final class ScheduledCommandType extends AbstractType
  {
      /**
       * @SuppressWarnings(PHPMD.UnusedFormalParameter)
       */
      public function buildForm(FormBuilderInterface $builder, array $options): void
      {
          $builder
              -&gt;add('name')
              -&gt;add('command', CommandChoiceType::class)
              -&gt;add('arguments')
              -&gt;add('cronExpression')
              -&gt;add('commandLimitRanges', CollectionType::class, [
                  'label' =&gt; 'sylius.ui.scheduled_command_limit',
                  'entry_type' =&gt; CommandLimitType::class,
                  'allow_add' =&gt; true,
                  'allow_delete' =&gt; true,
                  'by_reference' =&gt; false,
                  'inherit_data' =&gt; true,
                  'entry_options'  =&gt; array(
                          'scheduledCommand' =&gt; 'id'),
                  ])
              -&gt;add('logFile')
              -&gt;add('priority')
              -&gt;add('executeImmediately')
              -&gt;add('enabled')
          ;
      }
  
      public function configureOptions(OptionsResolver $resolver): void
      {
          $resolver-&gt;setDefaults([
              'data_class' =&gt; ScheduledCommand::class,
          ]);
      }
  } 
  </code></pre>
  <p>This is my entry Type:</p>
  <pre><code>class CommandLimitType extends AbstractType
  {
  
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
  
          $builder
              -&gt;add('timeTo', DateTimeType::class, [
                  'widget' =&gt; 'single_text',
  
              ])
              -&gt;add('timeFrom', DateTimeType::class, [
                  'widget' =&gt; 'single_text'
              ])
              -&gt;add('scheduledCommand', HiddenType::class)
          ;
      }
  
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setRequired(['scheduledCommand']);
          $resolver-&gt;setDefaults([
              'data_class' =&gt; ScheduledCommandLimitRange::class,
          ]);
      }
  }
  </code></pre>
  <p>I had a problem, that when I want to submit this form value CommandLimitRange parentId was null, so i tried to pass into child form parent Id as hidden field. But still got after submit there is stil error:</p>
  <pre><code>Cannot read index &quot;0&quot; from object of type &quot;Synolia\SyliusSchedulerCommandPlugin\Entity\ScheduledCommand&quot; because it doesn't implement \ArrayAccess.
  </code></pre>
  <p>What is correct way to pass parent entity Id into entry so that after submit correct parentId is linked to row in db?
  Thank you very much</p>