Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phalcon\Mvc\Model\Criteria::fromInput don't work well with columnMap #1903

Closed
sergiors opened this issue Jan 24, 2014 · 1 comment
Closed

Comments

@sergiors
Copy link

My model

class Orders extends ModelBase {
....
  public function columnMap() {
    return [
      'compra_id' => 'id',
      'compra_usuario_id' => 'user_id',
      'compra_endereco_entrega_id' => 'address_id',
      'compra_status_com_id' => 'status_id',
      'compra_formas_pag_id' => 'method_id',
      'compra_valor_total' => 'value',
      'compra_feita_em' => 'created_at',
      'excluida' => 'deleted',
      'excluida_em' => 'excluida_em'
    ];
  }
...

My controller

  if ($this->request->isPost()) {
      $query = Criteria::fromInput($this->di, 'Models\Orders', $this->request->getPost());
      $this->persistent->searchParams = $query->getParams();
   }

and my view

    <form method="post" action="{{ url('a/orders') }}" autocomplete="off">
        <div class="input-group">
          {{ text_field('value', 'class': 'form-control input-sm', 'placeholder': 'Pesquise por nome, número do pedido ou boleto', 'type': 'number') }}
          <span class="input-group-btn">
            <button type="submit" class="btn btn-default btn-sm"><i class="fa fa-search"></i></button>
          </span>
        </div>
      </form>

when I print $query->getParams() it gives me a NULL. But if i change the name of the input to compra_valor_total, the real column name all works well.

Is this a bug or a not common use case?

@phalcon
Copy link
Collaborator

phalcon commented Mar 6, 2014

Fixed in 1.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants