Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda