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

247
Views
How to name model rule on Yii2?

I just started learning Yii2 and I have a problem here. I want to set new rule on name field, which would replace all first letters to the uppercase, but I don't know how to set the rule name and I'm constantly getting error messages of it.

Now my model looks like this, I added regex, which is replacing letters to uppercase, but I've no idea how to write that empty string:

['name', 'required'],
        ['name', 'string', 'max' => 255,
            ' ' => '/(^|\s)[a-z]/g'],

Thank you for any help

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

For this simple case just use

['name', 'filter', 'filter' => 'ucfirst']

See docs for this one.

about 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!