The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

Retrieving input value from view to controller in slim framework

Giovane Lizot's Avatar

Giovane Lizot

28 Jul, 2020 08:42 PM

Hello, I have the following difficulty: I have a field that the user fills in with the value of the cnpj, I need to retrieve this value for the controller, set this dynamic value in a query within a method to be able to fill in a select on another page referring to this cnpj in question. I do not program in the slim framework, I am trying to do it for days, I would like an example or a way to implement a solution according to this need.

// This is the input that I should get the value

<input type="tel" class="form-control numeric" name="cgc" id="cgc" placeholder="CPF / CNPJ">
// this is the query that i must fill in with the return of the typed cnpj

public function getDevolucoes($request, $response, $args) {

    $cnpj = $request->getParam('cgc');

    $devolucoes = $this->database->query('
    select distinct
        dev_devolucoes.id_devolucao as cod_devolucao,
        dev_devolucoes.numeronf As nfvendaccgl,
        dev_devolucoes.numeronf_devolucao as nfdevolucaocliente,
        dev_itensdevolucao.quantidade_devolvida as quantidade
        itenscarregamento on itenspedido.iditenspedido = itenscarregamento.iditenspedido
        pedido on itenspedido.idpedido = pedido.idpedido
        dev_devolucoes on itenscarregamento.numeronf = dev_devolucoes.numeronf
        dev_itensdevolucao on dev_devolucoes.id_devolucao = dev_itensdevolucao.id_devolucao
        pedido.cnpj = :cgc AND
        dev_devolucoes.dev_status = :devstatusId
    ', [
        ':devstatusId' => '6',
        ':cgc' => $cnpj

    $response = $response->withJson($devolucoes);
    $response = $response->withAddedHeader('cache-control', 'no-cache');
    $response = $response->withAddedHeader('pragma', 'no-cache');
    $response = $response->withAddedHeader('expires', '0');

    return $devolucoes;
Thank you for your suggestions.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac