Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!