< ? php echo $this->element('register'); ?>
I created form in element, a same way in view.
<?php $customers = $this->requestAction('customers/add'); ?>
<div class="customers form">
<?php echo $this->Form->create('Customer'); ?>
<?php
echo $this->Form->input('salutation', array(
'options' => array('Mr' => 'Mr', 'Mrs' => 'Mrs', 'Ms' => 'Ms')
));
echo $this->Form->input('firstname', array('required' => true));
echo $this->Form->input('lastname', array('required' => true));
echo $this->Form->input('street', array('required' => true));
echo $this->Form->input('zip_city', array('required' => true));
echo $this->Form->input('country', array('required' => true));
echo $this->Form->input('phone', array('required' => true));
echo $this->Form->input('email', array('required' => true));
?>
<?php echo $this->Form->end($options); ?>
</div>
My controller for adding data in db:
public function add(){
if($this->request->is('customer')) {
$this->Customer->create();
if($this->Customer->save($this->request->data)){
$this->Session->setFlash('Register successiful');
}
$this->Session->setFlash('Unable to register!');
}
}
I think that is my problem in this line:
if($this->request->is('customer')) {
If I remove if-statement, I succedd to store data in table, but stored and more blank rows.
I appreciate every suggestion. Thanks
--
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:
Post a Comment