Proszę o pomoc
Po naciśnięciu przycisku submit kompletnie nic się nie dzieje, żadnego errora tylko chwile przeładuje się strzałka i nic...
Akcja Add z kontrolera :
public function addAction()
{
$form = new ProductForm();
$form->get('submit')->setValue('Add');
$request = $this->getRequest();
if($request->isPost()){
//nowy produkt
$product = new Product();
$form->setInputFilter($product->getInputFilter());
$form->setData($request->getPost());
if($form->isValid())
{
$product->exchangeArray($form->getData());
$this->getProductTable()->saveProduct($product);
return $this->redirect()->toRoute('product');
}
}
return array('form'=>$form);
}
Formularz wyglada tak:
<?php
namespace Product\Form;
use Zend\Form\Form;
class ProductForm extends Form {
public function __construct($name = null)
{
parent::__construct('product');
/*$this->setAttributes(array(
'method'=>'post')); nie potrzebne domyslny post w z2*/
$this->add(array(
'name'=>'id',
'type'=>'Hidden',
));
$this->add(array(
'name'=>'name',
'type'=>'Text',
'options'=>array(
'label'=>'Nazwa'
),
));
$this->add(array(
'name'=>'price',
'type'=>'Text',
'options'=>array(
'label'=>'Cena'
),
));
$this->add(array(
'name'=>'submit',
'type'=>'Submit',
'attributes'=>array(
'value'=>'Zapisz',
'id'=>'submitbutton',
'class'=>'btn btn-primary',
),
));
}
}
Sam widok:
<?php
$title = 'Dodaj Produkt';
$this->headTitle($title);
?>
<h1><?php echo $this->escapeHtml($title);?> </h1>
<?php
$form = $this->form;
$form->setAttribute('action',$this->url('product',array('action'=>'add')));
$form->prepare();
echo $this->form()->openTag($form);
echo $this->formHidden($form->get('id'));
echo $this->formRow($form->get('name'));
echo $this->formRow($form->get('price'));
echo $this->formSubmit($form->get('submit'));
echo $this->form()->closeTag($form);
?>
myślałem że to może wina bazy danych ale fetchAll działa więc czemu insert miałby nie...
firebug wyrzuca cos takiego
<form id="product" action="/Autostop/public/product/add" name="product" method="POST">
<input type="hidden" value="" name="id">
<label>
<span>Nazwa</span>
<input type="text" value="er" name="name">
</label>
<label>
<span>Cena</span>
<input type="text" value="33" name="price">
</label>
<input id="submitbutton" class="btn btn-primary" type="submit" value="Add" name="submit">
</form>