Tuesday, August 26, 2014

Re: unidentified index

You don't need to set the value in the input, instead you can do it from the controller.

if($this->request->is('post')) {
    // Logic to process the form submission
} else {
    $this->request->data = $this->Model->read(null, $id);
}

Change this part "echo $this->Form->create(null, array('url' => $loc));" to contain the model name, for example if this form is for the User model, do the following "echo $this->Form->create('User', array('url' => $loc));"

Alternatively you can specify the model in the input like such:

echo $this->Form->input('User.email', array('type'=>'text', 'label'=>'', 'after'=>'e-mail'));


On 26 August 2014 18:50, 'Dallas' via CakePHP <cake-php@googlegroups.com> wrote:
In migrating from 1.2.5 to 2.5.3 I am getting undefined index for input of name, business name, phone and email.  I updated form as much as possible - but if I use DataHelper - I can no longer use array - is there a quick way to fix this using isset() or do i need to rewrite - here is the code: - Thank you
echo '<div class="highlight-box">';
    echo $this->Form->create(null, array('url' => $loc)); 
    echo $this->Form->hidden('adv_form', array('value' => 'adv_form'));
    echo $this->Form->input('name', array('type'=>'text', 'value'=>$this->data['name'], 'label'=>'', 'after'=>'Contact Name'));
    if(array_key_exists('name', $this->Errors)){echo $this->Errors['name'];}
    echo $this->Form->input('business_name', array('type'=>'text', 'value'=>$this->data['business_name'], 'label'=>'', 'after'=>'Business Name'));
    echo $this->Form->input('phone', array('type'=>'text', 'value'=>$this->data['phone'], 'label'=>'', 'after'=>'Phone Number'));
    if(array_key_exists('phone', $this->Errors)){echo $this->Errors['phone'];}
    echo $this->Form->input('email', array('type'=>'text', 'value'=>$this->data['email'], 'label'=>'', 'after'=>'e-mail'));
    if(array_key_exists('email', $this->Errors)){echo $this->Errors['email'];}
    echo $this->Form->submit('add.gif');
    echo $this->Form->end();
    
    if($msg != '')
    {
        echo '<br />';
        echo $msg;
        echo '<br />';
    }
echo '</div>';
?>

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.



--
Kind Regards
 Stephen Speakman

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: