Send data from one table to another

Asked

Viewed 81 times

1

And the next thing I know, I have an Entity called the Post where there’s a record of a post and I have an Entity called the Machine. The goal is: inserir a descrição da imagem aqui

Having a table like this where we create a machine and on the buttons where you are seeing and editing instead of these will have one to convert. When we load there the line passes from the put Entity to machine Entity.

The code I already have is this: This at the Engine Ntity. inserir a descrição da imagem aqui

And in Maquinacontroller: inserir a descrição da imagem aqui

But make me wrong.

I made a screen printscrm so you can see better the error that appears to me. inserir a descrição da imagem aqui

  • 2

    Edit your question and add your code directly. The way it looks is hard to visualize.

  • What is the mistake that happens?

1 answer

1

From what I understand, you’re looking to convert an entity of the kind Posto to an entity of the type Maquina, right?

In his method createAction you are instantiating an entity of the type Maquina without filling in all its values. And the table exists that some values are non-null, as it accuses the error you posted.

In my view, the method should be something like this:

public function createAction($id)
{
    $posto = $this->getDoctrine()->getPostoRepository()->find($id);

    $maquina = new Maquina();
    $maquina->setNumero( $posto->getNumero() );
    $maquina->setDescricao( $posto->getNumero() );
    $maquina->setEndereco( $posto->getNumero() );
    $maquina->setestacao( $posto->getNumero() );
    $maquina->setProtocolo( $posto->getNumero() );
    $maquina->setAtivo( $posto->getNumero() );
    $maquina->setLer( $posto->getNumero() );
    $maquina->setDtype('maquina');

    $this->getDoctrine()->getManager()->persist($maquina);
    $this->getDoctrine()->getManager()->flush();

    return $this->redirect($this->generateUrl('manutencao_maquina', array('id' => $id)));
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.