Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
Yii - Update field

I have a template that corresponds to a table in the database and I need a form to edit only one field of that table, this table is made up of two primary keys.

For example, I have a table with 3 attributes, ID, ID2, and Name (Both ID and ID2 are primary keys). When I enter a user profile, I want it to fetch both ID's and only change the name field. What do I need to do?

I've already tried to create a form in the views where I want it to appear, and a function in the template that fetches the ID's from the user I'm searching. I can see the 'Name' field of that user, but I can not edit it.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Don't know exactly your problem. But for fetching list of primary key, you can use $yourModelInstance->primaryKey().

And about the name field to be updatable, you must specified rules for it in your model::rules function. Yii2 check for input rules before saving data as yii2 instructions. Here's an example:

in your Model class:

public function rules()
{
    return [
        [['name'], 'string'],
        [['your primary key 1', 'your primary key 2'], 'int'],
    ];
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda