Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6114985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:02:21+00:00 2026-05-23T15:02:21+00:00

I have my validation rules in model, and everything is fine. It validates like

  • 0

I have my validation rules in model, and everything is fine. It validates like I want to, but in the Edit actions, although it not validates, don’t show me de red error marks under textbox.

Any tip?

Thanks.

The Model Code(Model name is Safpercent):

var $validate = array(
        'sequencia' => array(
            'must_be_numeric' => array(
                'rule' => 'Numeric',
                'message' => 'Number Field: insert only numbers.' 
            )
        ),
    );

View Text Box:

echo $form->input('Safpercent.sequence', array('id' => 'sequence', 'options' => $criteria, 'label' => false, 'div' => false, 'style' => 'width: 300px'));

Controller Code:

function edit($id = null) {
                $criteria = $this->Safpercent->Safrequirement->find('list', array('fields' => array('Safrequirement.sequencia', 'Safrequirement.descricao'), 'conditions' => array('Safrequirement.tipo' => 'ILC')));
                $this->set('criteria', $criteria);
                if (!$id && empty($this->data)) {
                    $this->Session->setFlash(RecordNotValid, 'flash_failure');
                    $this->redirect(array('controller' => 'safpercents', 'action'=>'index'));
        }
        if (!empty($this->data)) {
                    $sequencia = $this->data['Safpercent']['sequencia'];
                    if($this->data['Safpercent']['tipo'] == ''){$tipo = 'ILC';}else{$tipo = $this->data['Safpercent']['tipo'];} 
                    $encontro = $this->Safpercent->Safrequirement->find('all', array('conditions' => array('sequencia' => $sequencia, 'tipo' => $tipo)));
            if($encontro <> array()){
                        if ($this->Safpercent->save($this->data)) {
                            $this->Session->setFlash(RecordSaved, 'flash_success');
                            $this->redirect(array('controller' => 'safpercents', 'action'=>'index'));
                        }else{
                            $this->Session->setFlash(RecordNotSaved, 'flash_failure');
                        }
                    }else{
                        $this->Session->setFlash('A Sequência que tentou Inserir não existe. Verifique a tabela de novo, por favor.');
                    }   
                }
        if (empty($this->data)) {
                    $this->data = $this->Safpercent->read(null, $id);
                    $this->set('id', $id);
        }
                $this->set('cod_percent',$this->Safpercent->read(null, $id));
    }

(Portuguese Variables and Text in some cases)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:02:21+00:00Added an answer on May 23, 2026 at 3:02 pm

    I see now. In your controller, you are using the sequencia field that you are validating, but not doing any validation at this stage. It passes a non-number to the find query, which then returns an error or something, and the save never gets called?

    Before you do this:

    $sequencia = $this->data['Safpercent']['sequencia'];
    

    You should check that the data validates, by calling this:

    $this->ModelName->set($this->data);
    if ($this->ModelName->validates()) {
        ... //do your business here
    

    So basically, change:

    if (!empty($this->data)) {
    

    to:

    $this->Safpercent->set($this->data);
    if (!empty($this->data) && $this->Safpercent->validates()) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a generated domain model using LLBLGEN, and im validating those validation rules
Hi I have been trying to access the validation rules of an associated model
I have a model with a number of validation rules, all of which are
I have a validation rules in my model: public function rules() { return array(){
I have the following code to enable validation work: $(document).ready(function() { $(#eventForm).validate({ rules: {
I have a class library that contains my object model. I'd like each object
My problem right now is that a Model has a set of Validation rules
I have started using jQuery Validation plugin 1.7. I have a wizard like interface
I have my own password/login rules that I want to implement such as: Password:
I want to build an object model that automatically wires in validation when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.