SlideShare a Scribd company logo
Radio1
• composer create-project symfony/website-skeleton symfony6
• cd symfony6
• php bin/console make:controller
>RadioController
• composer php/bin server:start
• http://localhost:8000/copy
Vederea base.html.twig
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock
%}</title>
{% block stylesheets %}{% endblock %}
</head>
<body bgcolor="aquamarine">
{% block body %}{% endblock %}
{% block javascripts %}{% endblock %}
</body>
</html>
Vederea radio/index.html.twig
{% extends 'base.html.twig' %}
{% block title %}Copy!{% endblock %}
{% block body %}
{{head|raw}}
{{ form_start(form) }}
{{ form_row(form.radio) }}
{{ form_end(form) }}
{% endblock %}
Vederea radio/output.html.twig
{% extends 'base.html.twig' %}
{% block title %}Copy!{% endblock %}
{% block body %}
{{value|raw}}
{% endblock %}
Controller-ul RadioController
<?php
namespace AppController;
use SymfonyComponentRoutingAnnotationRoute;
use SymfonyBundleFrameworkBundleControllerController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentForm;
use SymfonyComponentFormExtensionCoreTypeTextType;
use SymfonyComponentFormExtensionCoreTypeSubmitType;
use SymfonyComponentFormExtensionCoreTypeRadioType;
use SymfonyComponentFormExtensionCoreTypeChoiceType;
class RadioController extends Controller
{
/**
* @Route("/radio", name="radio")
*/
public function index(Request $request)
{
$data=[];
$form=$this->createFormBuilder()
->setAction($this->generateUrl('output'))//se utilizeaza numele controlului
adnotat!!!
->setMethod('POST')
->add('radio', ChoiceType::class, array(
'choices' => array('Popescu' => 'Popescu', 'Ionescu' => 'Ionescu',
'Georgescu'=>'Georgescu'),
'expanded' => true,
'multiple' => false,
'label'=>false,
))
->add('submit', SubmitType::class)
->getForm();
$form->handleRequest($request);
$data['head']="<h1>Choose:</h1>";
$data['form']=$form->createView();
if($form->isSubmitted()){
switch($form->get('radio')->getData()){
case 'Popescu':
$data['value'] = 'Popescu';
break;
case 'Ionescu';
$data['value'] = 'Ionescu';
break;
case 'Georgescu';
$data['value'] = 'Georgescu';
break;
default:
$data['value'] = 'Vai! vai! vai!';
}
}
return $this->render('radio/index.html.twig', $data);
}
/**
* @Route("/output", name="output")
*/
public function output(Request $request)
{
$var = $request->request->all();
$data['value']="Hello <b>".$var['form']['radio']."</b>!";
return $this->render('radio/output.html.twig', $data);
}
}

More Related Content

Similar to 8. radio1 in Symfony 4

13. view data
13. view data13. view data
13. view data
Razvan Raducanu, PhD
 
Simple Markdown with Ecto and Protocols
Simple Markdown with Ecto and ProtocolsSimple Markdown with Ecto and Protocols
Simple Markdown with Ecto and Protocols
David Lucia
 
Html5 intro
Html5 introHtml5 intro
Html5 intro
Kevin DeRudder
 
[In Control 2010] HTML5
[In Control 2010] HTML5[In Control 2010] HTML5
[In Control 2010] HTML5
Christopher Schmitt
 
Making Sense of Twig
Making Sense of TwigMaking Sense of Twig
Making Sense of Twig
Brandon Kelly
 
Html 5
Html 5Html 5
What you need to know bout html5
What you need to know bout html5What you need to know bout html5
What you need to know bout html5
Kevin DeRudder
 
DRYing Up Rails Views and Controllers
DRYing Up Rails Views and ControllersDRYing Up Rails Views and Controllers
DRYing Up Rails Views and Controllers
James Gray
 
PhpBB meets Symfony2
PhpBB meets Symfony2PhpBB meets Symfony2
PhpBB meets Symfony2
Fabien Potencier
 
WebSockets with Spring 4
WebSockets with Spring 4WebSockets with Spring 4
WebSockets with Spring 4
Sergi Almar i Graupera
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
Hugo Hamon
 
18. images in symfony 4
18. images in symfony 418. images in symfony 4
18. images in symfony 4
Razvan Raducanu, PhD
 
Print this
Print thisPrint this
Print this
himanii313
 
Coding for entrepreneurs
Coding for entrepreneursCoding for entrepreneurs
Coding for entrepreneurs
Amine Sadry
 
Attractive HTML5~開発者の視点から~
Attractive HTML5~開発者の視点から~Attractive HTML5~開発者の視点から~
Attractive HTML5~開発者の視点から~
Sho Ito
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
danpaquette
 
Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel
Engine Yard
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
Max Claus Nunes
 
1 Introduction to PHP Overview This lab walks y.docx
1  Introduction to PHP Overview This lab walks y.docx1  Introduction to PHP Overview This lab walks y.docx
1 Introduction to PHP Overview This lab walks y.docx
honey725342
 
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTERSINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
Elber Ribeiro
 

Similar to 8. radio1 in Symfony 4 (20)

13. view data
13. view data13. view data
13. view data
 
Simple Markdown with Ecto and Protocols
Simple Markdown with Ecto and ProtocolsSimple Markdown with Ecto and Protocols
Simple Markdown with Ecto and Protocols
 
Html5 intro
Html5 introHtml5 intro
Html5 intro
 
[In Control 2010] HTML5
[In Control 2010] HTML5[In Control 2010] HTML5
[In Control 2010] HTML5
 
Making Sense of Twig
Making Sense of TwigMaking Sense of Twig
Making Sense of Twig
 
Html 5
Html 5Html 5
Html 5
 
What you need to know bout html5
What you need to know bout html5What you need to know bout html5
What you need to know bout html5
 
DRYing Up Rails Views and Controllers
DRYing Up Rails Views and ControllersDRYing Up Rails Views and Controllers
DRYing Up Rails Views and Controllers
 
PhpBB meets Symfony2
PhpBB meets Symfony2PhpBB meets Symfony2
PhpBB meets Symfony2
 
WebSockets with Spring 4
WebSockets with Spring 4WebSockets with Spring 4
WebSockets with Spring 4
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
18. images in symfony 4
18. images in symfony 418. images in symfony 4
18. images in symfony 4
 
Print this
Print thisPrint this
Print this
 
Coding for entrepreneurs
Coding for entrepreneursCoding for entrepreneurs
Coding for entrepreneurs
 
Attractive HTML5~開発者の視点から~
Attractive HTML5~開発者の視点から~Attractive HTML5~開発者の視点から~
Attractive HTML5~開発者の視点から~
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
1 Introduction to PHP Overview This lab walks y.docx
1  Introduction to PHP Overview This lab walks y.docx1  Introduction to PHP Overview This lab walks y.docx
1 Introduction to PHP Overview This lab walks y.docx
 
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTERSINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
 

More from Razvan Raducanu, PhD

12. edit record
12. edit record12. edit record
12. edit record
Razvan Raducanu, PhD
 
11. delete record
11. delete record11. delete record
11. delete record
Razvan Raducanu, PhD
 
10. view one record
10. view one record10. view one record
10. view one record
Razvan Raducanu, PhD
 
9. add new record
9. add new record9. add new record
9. add new record
Razvan Raducanu, PhD
 
8. vederea inregistrarilor
8. vederea inregistrarilor8. vederea inregistrarilor
8. vederea inregistrarilor
Razvan Raducanu, PhD
 
7. copy1
7. copy17. copy1
6. hello popescu 2
6. hello popescu 26. hello popescu 2
6. hello popescu 2
Razvan Raducanu, PhD
 
5. hello popescu
5. hello popescu5. hello popescu
5. hello popescu
Razvan Raducanu, PhD
 
4. forme in zend framework 3
4. forme in zend framework 34. forme in zend framework 3
4. forme in zend framework 3
Razvan Raducanu, PhD
 
3. trimiterea datelor la vederi
3. trimiterea datelor la vederi3. trimiterea datelor la vederi
3. trimiterea datelor la vederi
Razvan Raducanu, PhD
 
2.routing in zend framework 3
2.routing in zend framework 32.routing in zend framework 3
2.routing in zend framework 3
Razvan Raducanu, PhD
 
1. zend framework intro
1. zend framework intro1. zend framework intro
1. zend framework intro
Razvan Raducanu, PhD
 
17. delete data
17. delete data17. delete data
17. delete data
Razvan Raducanu, PhD
 
16. edit data
16. edit data16. edit data
16. edit data
Razvan Raducanu, PhD
 
15. view single data
15. view single data15. view single data
15. view single data
Razvan Raducanu, PhD
 
14. add data in symfony4
14. add data in symfony4 14. add data in symfony4
14. add data in symfony4
Razvan Raducanu, PhD
 
12.doctrine view data
12.doctrine view data12.doctrine view data
12.doctrine view data
Razvan Raducanu, PhD
 
10. add in Symfony 4
10. add in Symfony 410. add in Symfony 4
10. add in Symfony 4
Razvan Raducanu, PhD
 
1.symfony 4 intro
1.symfony 4 intro1.symfony 4 intro
1.symfony 4 intro
Razvan Raducanu, PhD
 
23.simple login with sessions in laravel 5
23.simple login with sessions in laravel 523.simple login with sessions in laravel 5
23.simple login with sessions in laravel 5
Razvan Raducanu, PhD
 

More from Razvan Raducanu, PhD (20)

12. edit record
12. edit record12. edit record
12. edit record
 
11. delete record
11. delete record11. delete record
11. delete record
 
10. view one record
10. view one record10. view one record
10. view one record
 
9. add new record
9. add new record9. add new record
9. add new record
 
8. vederea inregistrarilor
8. vederea inregistrarilor8. vederea inregistrarilor
8. vederea inregistrarilor
 
7. copy1
7. copy17. copy1
7. copy1
 
6. hello popescu 2
6. hello popescu 26. hello popescu 2
6. hello popescu 2
 
5. hello popescu
5. hello popescu5. hello popescu
5. hello popescu
 
4. forme in zend framework 3
4. forme in zend framework 34. forme in zend framework 3
4. forme in zend framework 3
 
3. trimiterea datelor la vederi
3. trimiterea datelor la vederi3. trimiterea datelor la vederi
3. trimiterea datelor la vederi
 
2.routing in zend framework 3
2.routing in zend framework 32.routing in zend framework 3
2.routing in zend framework 3
 
1. zend framework intro
1. zend framework intro1. zend framework intro
1. zend framework intro
 
17. delete data
17. delete data17. delete data
17. delete data
 
16. edit data
16. edit data16. edit data
16. edit data
 
15. view single data
15. view single data15. view single data
15. view single data
 
14. add data in symfony4
14. add data in symfony4 14. add data in symfony4
14. add data in symfony4
 
12.doctrine view data
12.doctrine view data12.doctrine view data
12.doctrine view data
 
10. add in Symfony 4
10. add in Symfony 410. add in Symfony 4
10. add in Symfony 4
 
1.symfony 4 intro
1.symfony 4 intro1.symfony 4 intro
1.symfony 4 intro
 
23.simple login with sessions in laravel 5
23.simple login with sessions in laravel 523.simple login with sessions in laravel 5
23.simple login with sessions in laravel 5
 

Recently uploaded

How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
สมใจ จันสุกสี
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 

Recently uploaded (20)

How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
คำศัพท์ คำพื้นฐานการอ่าน ภาษาอังกฤษ ระดับชั้น ม.1
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 

8. radio1 in Symfony 4

  • 2. • composer create-project symfony/website-skeleton symfony6 • cd symfony6 • php bin/console make:controller >RadioController • composer php/bin server:start • http://localhost:8000/copy
  • 3. Vederea base.html.twig <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>{% block title %}Welcome!{% endblock %}</title> {% block stylesheets %}{% endblock %} </head> <body bgcolor="aquamarine"> {% block body %}{% endblock %} {% block javascripts %}{% endblock %} </body> </html>
  • 4. Vederea radio/index.html.twig {% extends 'base.html.twig' %} {% block title %}Copy!{% endblock %} {% block body %} {{head|raw}} {{ form_start(form) }} {{ form_row(form.radio) }} {{ form_end(form) }} {% endblock %}
  • 5. Vederea radio/output.html.twig {% extends 'base.html.twig' %} {% block title %}Copy!{% endblock %} {% block body %} {{value|raw}} {% endblock %}
  • 6. Controller-ul RadioController <?php namespace AppController; use SymfonyComponentRoutingAnnotationRoute; use SymfonyBundleFrameworkBundleControllerController; use SymfonyComponentHttpFoundationRequest; use SymfonyComponentHttpFoundationResponse; use SymfonyComponentForm; use SymfonyComponentFormExtensionCoreTypeTextType; use SymfonyComponentFormExtensionCoreTypeSubmitType; use SymfonyComponentFormExtensionCoreTypeRadioType; use SymfonyComponentFormExtensionCoreTypeChoiceType;
  • 7. class RadioController extends Controller { /** * @Route("/radio", name="radio") */ public function index(Request $request) { $data=[]; $form=$this->createFormBuilder() ->setAction($this->generateUrl('output'))//se utilizeaza numele controlului adnotat!!! ->setMethod('POST') ->add('radio', ChoiceType::class, array( 'choices' => array('Popescu' => 'Popescu', 'Ionescu' => 'Ionescu', 'Georgescu'=>'Georgescu'), 'expanded' => true, 'multiple' => false, 'label'=>false, )) ->add('submit', SubmitType::class) ->getForm(); $form->handleRequest($request); $data['head']="<h1>Choose:</h1>"; $data['form']=$form->createView();
  • 8. if($form->isSubmitted()){ switch($form->get('radio')->getData()){ case 'Popescu': $data['value'] = 'Popescu'; break; case 'Ionescu'; $data['value'] = 'Ionescu'; break; case 'Georgescu'; $data['value'] = 'Georgescu'; break; default: $data['value'] = 'Vai! vai! vai!'; } } return $this->render('radio/index.html.twig', $data); }
  • 9. /** * @Route("/output", name="output") */ public function output(Request $request) { $var = $request->request->all(); $data['value']="Hello <b>".$var['form']['radio']."</b>!"; return $this->render('radio/output.html.twig', $data); } }