Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

12. edit record

386 views

Published on

http://www.rraducanu.ro

Published in: Education
  • Be the first to comment

  • Be the first to like this

12. edit record

  1. 1. Edit record
  2. 2. IndexController public function editAction() { $id=(int)$this->params()->fromRoute('id',0); if($id==0){ exit('invalid id'); } $flower=$this->table->getFlower($id); $form=new DataFormMyForm(); $form->bind($flower); $request=$this->getRequest(); if(!$request->isPost()) { return new ViewModel(['form'=>$form,'id'=>$id]); } $form->setData($request->getPost()); if(!$form->isValid()){ exit('not valid'); } $this->table->saveFlower($flower); $this->redirect()->toRoute('data',['action'=>'index']); }
  3. 3. view/data/index/edit.phtml <h1>Edit</h1> <?php $form->setAttribute('action',$this->url('data',['action'=>'edit','id'=>$id])); $form->prepare(); echo $this->form()->openTag($form); echo $this->formHidden($form->get('id')); echo $this->formRow($form->get('nume')); echo "<br/><br/>"; echo $this->formRow($form->get('culoare')); echo "<br/><br/>"; echo $this->formRow($form->get('marime')); echo "<br/><br/>"; echo $this->formRow($form->get('pret')); echo "<br/><br/>"; echo $this->formSubmit($form->get('submit')); echo $this->form()->closeTag();

×