Copy1
FormController
…………………….
public function copy1Action()
{
$form=new FormeFormMyForm();
$viewModel = new ViewModel(array('form'=>$form));
$viewModel->setTemplate('forme/index/copy1_form');
return $viewModel;
}
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;
}
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();
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();
module/Forme/config/module.config.php
……………
'copy1' => [
'type' => Literal::class,
'options' => [
'route' => '/copy',
'defaults' => [
'controller' => ControllerFormController::class,
'action' => 'copy1',
],
],
],
……………………………………..
'showcopy1' => [
'type' => Literal::class,
'options' => [
'route' => '/showcopy',
'defaults' => [
'controller' => ControllerFormController::class,
'action' => 'showcopy1',
],
],
],
…………………………………
……………….
'controllers' => [
'factories' => [
ControllerIndexController::class => InvokableFactory::class,
ControllerFormController::class=>InvokableFactory::class,
],
………………………….
………………………..
'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',
……………………………….
],
………………………
/src/Form/MyForm.php
…………….
public function __construct()
{
parent::__construct('myform');//my_form este numele
formei
$this->setAttribute('method', 'post');
$this->setAttribute('action', '/showcopy');
//text
$this->add([
'type'=>'text',
'name'=>'nume1',
'options'=>[
'label'=>'Nume1'
]
]);
//text
$this->add([
'type'=>'text',
'name'=>'nume2',
'options'=>[
'label'=>'Nume2'
]
]);
//submit
$this->add([
'type'=>'submit',
'name'=>'submit',
'attributes'=>[
'value'=>'Copy'
]
]);

7. copy1