Contenu connexe Plus de Razvan Raducanu, PhD (20) 4. forme in zend framework 33. • Creati modulul Forme
si apoi efectuati toate configurarile necesare.
composer update !!!!!
5. MyForm.php
<?php
namespace FormeForm;
use ZendFormForm;
// A feedback form model
class MyForm extends Form
{
// Constructor.
public function __construct()
{
parent::__construct('myform');//my_form este numele formei
$this->setAttribute('method', 'post');
//text
$this->add([
'type'=>'text',
'name'=>'nume',
'options'=>[
'label'=>'Nume'
]
]);
6. //text
$this->add([
'type'=>'text',
'name'=>'prenume',
'options'=>[
'label'=>'Prenume'
]
]);
//password
$this->add([
'type'=>'password',
'name'=>'password',
'options'=>[
'label'=>'Password'
]
]);
//textarea
$this->add([
'type'=>'textarea',
'name'=>'textarea',
'attributes'=>[
'rows'=>'5',
'cols'=>'30',
],
'options'=>[
'label'=>'Textarea',
]
]);
7. //radio
$this->add([
'type'=>'radio',
'name'=>'radio',
'options'=>[
'label'=>'Choose: ',
'value_options'=>[
'0'=>'Negruzzi',
'1'=>'National',
'2'=>'Informatica',
],
]
]);
//checkbox1
$this->add([
'type'=>'checkbox',
'name'=>'check1',
'options'=>[
'label'=>'Iasi',
'check_value'=>'Iasi',
'uncheck_value'=>'0'
]
]);
9. //select
$this->add([
'type'=>'select',
'name'=>'dropdown',
'options'=>[
'label'=>'Choose: ',
'value_options'=>[
'0'=>'Negruzzi',
'1'=>'National',
'2'=>'Informatica',
],
]
]);
//list select
$this->add([
'type'=>'MonthSelect',
'name'=>'month',
'options'=>[
'label'=>'Select a month and a year. ',
'min_year'=>'2000',
]
]);
12. echo $this->formRow($form->get('nume'));
echo '<br/>';
echo $this->formRow($form->get('prenume'));
echo '<br/>';
echo $this->formRow($form->get('password'));
echo '<br/>';
echo $this->formRow($form->get('textarea'));
echo '<br/>';
echo $this->formRow($form->get('radio'));
echo '<br/>';
echo $this->formRow($form->get('check1'));
echo $this->formRow($form->get('check2'));
echo $this->formRow($form->get('check3'));
echo '<br/>';
16. ……………………………..
'forme' => [
'type' => Segment::class,
'options' => [
'route' => '/forme[/:action]',
'defaults' => [
'controller' => ControllerIndexController::class,
'action' => 'index',
],
…………………………………
17. 'view_manager' => [
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => [
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'forme/index/index' => __DIR__ . '/../view/forme/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
],