Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Something wrong with relations

Open
#516 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php, symfony, typescript
Domain
api, frontend

Research direction

Start with App.js and the HydraAdmin relation form for ProposalParam, then inspect the network request generated when selecting ProposalType. Compare the field metadata with the entity relation and API response; the issue is resolved when the ManyToOne field submits a ProposalType IRI rather than a nested array.

Written by the indexing model from the issue text.

Description

PHP: 8.2
Symfony: ^6
Api platform: ^3.2
Admin api platform: ^3.4.4

I created entity ProposalType.php

#[ORM\OneToMany(mappedBy: 'proposalType', targetEntity: ProposalParam::class)]
private Collection $proposalParams;

    public function __construct()
    {
        $this->proposalParams = new ArrayCollection();
    }

    public function getProposalParams(): Collection
    {
        return $this->proposalParams;
    }

    public function addProposalParam(ProposalParam $proposalParam): static
    {
        if (!$this->proposalParams->contains($proposalParam)) {
            $this->proposalParams->add($proposalParam);
            $proposalParam->setProposalType($this);
        }

        return $this;
    }

    public function removeProposalParam(ProposalParam $proposalParam): static
    {
        if ($this->proposalParams->removeElement($proposalParam)) {
            // set the owning side to null (unless already changed)
            if ($proposalParam->getProposalType() === $this) {
                $proposalParam->setProposalType(null);
            }
        }

        return $this;
    }

And another entity ProposalParam.php

    #[ORM\ManyToOne(inversedBy: 'proposalParams')]
    #[ORM\JoinColumn(nullable: false)]
    private ?ProposalType $proposalType = null;
    
    public function getProposalType(): ?ProposalType
    {
        return $this->proposalType;
    }

    public function setProposalType(?ProposalType $proposalType): static
    {
        $this->proposalType = $proposalType;

        return $this;
    }

This is pretty simple ManyToOne relation. Generated by make:entity. I'm dont modified this.
Wanted that ProposalParam entity has ProposalType entity by relation, it is simple.

I can create ProposalType via api platform with POST request to /api/proposal_types. And it is successfull.
Then i can set this ProposalType in ProposalParam via POST request to /api/proposal_types. And it is successfull.
Records are inside database and set up like needed.

When i go to admin panel and send request to create ProposalParam i can set ProposalType.

image

But request sends as array

Без имени

And error occured Nested documents for attribute "proposalType" are not allowed. Use IRIs instead.
And this is expected, we send array, but api wants IRI.

App.js in admin pretty standart, do not modify something

import { HydraAdmin } from "@api-platform/admin";

export default () => (
    <HydraAdmin entrypoint="http://localhost:9191/api" />
);

Main goal is why system generate select where i need to specify array of ProposalTypes, instead of one ProposalType. Can someone help with it?

Dominant language
TypeScript
Stars
516
Forks
134
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from api-platform/admin

All issues in api-platform/admin

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.