Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

7. copy1

42 vues

Publié le

http://www.rraducanu.ro

Publié dans : Formation
  • Login to see the comments

  • Soyez le premier à aimer ceci

7. copy1

  1. 1. Copy1
  2. 2. FormController ……………………. public function copy1Action() { $form=new FormeFormMyForm(); $viewModel = new ViewModel(array('form'=>$form)); $viewModel->setTemplate('forme/index/copy1_form'); return $viewModel; }
  3. 3. public function showcopy1Action() { $form=new FormeFormMyForm(); if(empty($_POST["nume1"])){ $msg="Hello! Please return and enter your name: <br/>"; }else{ $msg=$_POST["nume1"]; } $viewModel = new ViewModel(array('msg' => $msg,'form'=>$form)); $viewModel->setTemplate('forme/index/copy1_show'); return $viewModel; }
  4. 4. view/forme/index/copy1_form.phtml <?php $form->prepare(); echo $this->form()->openTag($form); echo $this->formRow($form->get('nume1')); echo $this->formSubmit($form->get('submit')); echo $this->formRow($form->get('nume2')); echo $this->form()->closeTag();
  5. 5. view/forme/index/copy1_show.phtml <?php $form->prepare(); echo $this->form()->openTag($form); echo $this->formRow($form->get('nume1')); echo $this->formSubmit($form->get('submit')); echo $this->formRow($form->get('nume2')->setAttributes(['value'=>$msg])); echo $this->form()->closeTag();
  6. 6. module/Forme/config/module.config.php …………… 'copy1' => [ 'type' => Literal::class, 'options' => [ 'route' => '/copy', 'defaults' => [ 'controller' => ControllerFormController::class, 'action' => 'copy1', ], ], ], ……………………………………..
  7. 7. 'showcopy1' => [ 'type' => Literal::class, 'options' => [ 'route' => '/showcopy', 'defaults' => [ 'controller' => ControllerFormController::class, 'action' => 'showcopy1', ], ], ], …………………………………
  8. 8. ………………. 'controllers' => [ 'factories' => [ ControllerIndexController::class => InvokableFactory::class, ControllerFormController::class=>InvokableFactory::class, ], ………………………….
  9. 9. ……………………….. 'view_manager' => [ 'display_not_found_reason' => true, 'display_exceptions' => true, 'doctype' => 'HTML5', 'not_found_template' => 'error/404', 'exception_template' => 'error/index', ……………………………………….. 'forme/index/copy' => __DIR__ . '/../view/forme/index/copy1_form.phtml', 'forme/index/showcopy' => __DIR__ . '/../view/forme/index/copy1_show.phtml', ………………………………. ], ………………………
  10. 10. /src/Form/MyForm.php ……………. public function __construct() { parent::__construct('myform');//my_form este numele formei $this->setAttribute('method', 'post'); $this->setAttribute('action', '/showcopy');
  11. 11. //text $this->add([ 'type'=>'text', 'name'=>'nume1', 'options'=>[ 'label'=>'Nume1' ] ]); //text $this->add([ 'type'=>'text', 'name'=>'nume2', 'options'=>[ 'label'=>'Nume2' ] ]);
  12. 12. //submit $this->add([ 'type'=>'submit', 'name'=>'submit', 'attributes'=>[ 'value'=>'Copy' ] ]);

×