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

  • Home
  • SEARCH
  • 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 8342511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:47:47+00:00 2026-06-09T05:47:47+00:00

The MODEL class CompanyCategory extends AppModel { public $name = CompanyCategory; public $hasMany =

  • 0

The MODEL

class CompanyCategory extends AppModel
{
    public $name = "CompanyCategory";

    public $hasMany = array(
        "Company"
    );
}

The CONTROLLER

public function admin_edit($id = null){

            //debug($this->request);
            //exit(0);
            if($id == null){
                $this->Session->setFlash("ID categorie eronat!", "flash/simpla_error");
                $this->redirect("index");
            }
            if($this->request->is('post')){
                if($this->CompanyCategory->save($this->request->data)){
                    $this->Session->setFlash("Categoria a fost salvata!", "flash/simpla_success");
                }
                else{
                    $this->Session->setFlash("Categoria NU a fost salvata!", "flash/simpla_error");
                }
            }
            else{
                $this->Session->setFlash("READ!", "flash/simpla_error");
                $this->request->data = $this->CompanyCategory->read(null, $id);
            }
        }

The VIEW

<div class="content-box">
    <div class="content-box-header">
        <h3>Editeaza categorie firme</h3>
    </div>
    <div class="content-box-content">
        <?php
            echo $this->Form->create("CompanyCategory", array(
                'inputDefaults' => array(
                    'error' => array(
                        'attributes' => array(
                            'wrap' => 'span', 
                            'class' => 'input-notification error png_bg'
                        )                   
                    )
                )
            ));
        ?>

        <?=$this->Form->input('id', array('type' => 'hidden'))?>

        <?=$this->Form->input('title', array('class' => "text-input small-input", 'label' => 'Denumire'))?>

        <?=$this->Form->submit('Salveaza', array('class' => "button"))?>
    </div>
</div>

My problem is that when submiting the form, the controller returns false for request->is(‘false’);

If I set explicitly in the view to the form helper inside the create method the type as ‘post’ it works as expected.

It is a little bit frustrating while the form method is already post without setting it.

Am I doing something wrong ?

  • 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-06-09T05:47:49+00:00Added an answer on June 9, 2026 at 5:47 am

    use this controller

    public function admin_edit($id = null) {
            $this->layout = 'admin_layout';
            $this->CompanyCategory->id = $id;
            if (!$this->CompanyCategory->exists()) {
                throw new NotFoundException(__('Invalid CompanyCategory model'));
            }
            if ($this->request->is('post') || $this->request->is('put')) {
                if ($this->CompanyCategory->save($this->request->data)) {
                    $this->Session->setFlash(__('The CompanyCategory model has been saved'));
                    $this->redirect(array('action' => 'index'));
                } else {
                    $this->Session->setFlash(__('The CompanyCategory model could not be saved. Please, try again.'));
                }
            } else {
                $this->request->data = $this->CompanyCategory->read(null, $id);
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following model : class Model extends BaseModel { public function save($conn
Assume this model class : public class Car extends Vehicle implements Visitable { .....
If I have this model: class Person(models.Model): name=models.CharField(max_length=28) mother=models.ForeignKey(self,null=True,blank=True) I am trying to make
model: class Author{ String name static hasMany = [books: Book] } class Book{ String
I have a Fruit model class: public class Fruit{ private String name; private String
My model: class Biz_model extends Model{ function allInfo(){ $q = $this->db->get('negocios'); if($q->num_rows() > 0){
Here is my model: class Company(models.Model): id = models.AutoField(primary_key=True); name = models.CharField(max_length=100); address =
I have a model: class picture(models.Model): name = models.CharField(null=False, blank=False, max_length=128) collections = models.ManyToManyField('collection',
#model class Promotion(models.Model): name = models.CharField(max_length=200) start_date = models.DateTimeField() end_date = models.DateTimeField() #view def
My model class is like this: Public class abc { public string p1 get;

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.