SlideShare a Scribd company logo
Form API – Drupal 8
Крайнюк Михаил
Drupal 8 – объектно-ориентирован.
Form API теперь тоже…
<?php
/**
* @file
* Contains DrupalExampleFormExampleForm.
*/
namespace DrupalexampleForm;
use DrupalCoreFormFormInterface;
/**
* Provides a simple example form.
*/
class ExampleForm implements FormInterface {
}
public function getFormID()
public function buildForm(array $form, array &$form_state)
public function validateForm(array &$form, array &$form_state)
public function submitForm(array &$form, array &$form_state)
public function buildForm(array $form, array &$form_state) {
$form['my_text_field'] = array(
'#type' => 'textfield',
'#title' => 'Example',
);
return $form;
}
Form Builder
public function validateForm(array $form, FormStateInterface &$form_state) {
if (strlen($form_state->getValue('phone_number')) < 3) {
$form_state->setErrorByName('phone_number', $this->t('The phone number is too short.'));
}
}
Form Validate
use DrupalsystemSystemConfigFormBase;
class ExampleConfigForm extends SystemConfigFormBase {
/**
* Implements DrupalCoreFormFormInterface::getFormID().
*/
public function getFormID() {
return 'example_systemconfigformbase';
}
/**
* Implements DrupalCoreFormFormInterface::buildForm().
*/
public function buildForm(array $form, array &$form_state) {
$form = parent::buildForm($form, $form_state);
// Use the Form API to define form elements.
return $form;
}
…
system_settings_form()
Спасибо!
Крайнюк Михаил
kraynuk.m@i20.biz

More Related Content

What's hot

20. CodeIgniter edit images
20. CodeIgniter edit images20. CodeIgniter edit images
20. CodeIgniter edit images
Razvan Raducanu, PhD
 
Ch6(mysql front)
Ch6(mysql front)Ch6(mysql front)
Ch6(mysql front)
Chhom Karath
 
Built-in Fake Objects
Built-in Fake ObjectsBuilt-in Fake Objects
Built-in Fake Objects
Yegor Bugayenko
 
Михаил Крайнюк. Form api: ajax-commands
Михаил Крайнюк. Form api: ajax-commandsМихаил Крайнюк. Form api: ajax-commands
Михаил Крайнюк. Form api: ajax-commands
Ksenia Rogachenko
 
8. vederea inregistrarilor
8. vederea inregistrarilor8. vederea inregistrarilor
8. vederea inregistrarilor
Razvan Raducanu, PhD
 
Php variables
Php variablesPhp variables
Php variables
Ritwik Das
 
WordPress: From Antispambot to Zeroize
WordPress: From Antispambot to ZeroizeWordPress: From Antispambot to Zeroize
WordPress: From Antispambot to Zeroize
Yoav Farhi
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operators
Khem Puthea
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
Eyal Vardi
 
Angular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time CompilationAngular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time Compilation
Eyal Vardi
 
Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0
Eyal Vardi
 
Codeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate UriCodeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate Uri
Abdul Malik Ikhsan
 
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xAngular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.x
Eyal Vardi
 
WordCamp Denver 2012 - Custom Meta Boxes
WordCamp Denver 2012 - Custom Meta BoxesWordCamp Denver 2012 - Custom Meta Boxes
WordCamp Denver 2012 - Custom Meta Boxes
Jeremy Green
 
Feeds drupal cafe
Feeds drupal cafeFeeds drupal cafe
Feeds drupal cafe
Andrii Podanenko
 
Dolibarr - information for developers and partners - devcamp Pau 2019
Dolibarr - information for developers and partners - devcamp Pau 2019Dolibarr - information for developers and partners - devcamp Pau 2019
Dolibarr - information for developers and partners - devcamp Pau 2019
Laurent Destailleur
 
Django class based views
Django class based viewsDjango class based views
Django class based viewsjustinvoss
 

What's hot (18)

20. CodeIgniter edit images
20. CodeIgniter edit images20. CodeIgniter edit images
20. CodeIgniter edit images
 
Ch6(mysql front)
Ch6(mysql front)Ch6(mysql front)
Ch6(mysql front)
 
Built-in Fake Objects
Built-in Fake ObjectsBuilt-in Fake Objects
Built-in Fake Objects
 
Михаил Крайнюк. Form api: ajax-commands
Михаил Крайнюк. Form api: ajax-commandsМихаил Крайнюк. Form api: ajax-commands
Михаил Крайнюк. Form api: ajax-commands
 
8. vederea inregistrarilor
8. vederea inregistrarilor8. vederea inregistrarilor
8. vederea inregistrarilor
 
Php variables
Php variablesPhp variables
Php variables
 
WordPress: From Antispambot to Zeroize
WordPress: From Antispambot to ZeroizeWordPress: From Antispambot to Zeroize
WordPress: From Antispambot to Zeroize
 
Php using variables-operators
Php using variables-operatorsPhp using variables-operators
Php using variables-operators
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
 
Angular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time CompilationAngular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time Compilation
 
Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0
 
Codeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate UriCodeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate Uri
 
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.xAngular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.x
 
WordCamp Denver 2012 - Custom Meta Boxes
WordCamp Denver 2012 - Custom Meta BoxesWordCamp Denver 2012 - Custom Meta Boxes
WordCamp Denver 2012 - Custom Meta Boxes
 
Feeds drupal cafe
Feeds drupal cafeFeeds drupal cafe
Feeds drupal cafe
 
Dolibarr - information for developers and partners - devcamp Pau 2019
Dolibarr - information for developers and partners - devcamp Pau 2019Dolibarr - information for developers and partners - devcamp Pau 2019
Dolibarr - information for developers and partners - devcamp Pau 2019
 
Advanced theming
Advanced themingAdvanced theming
Advanced theming
 
Django class based views
Django class based viewsDjango class based views
Django class based views
 

Similar to Mikhail Kraynuk. Form api. Drupal 8

Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAXМихаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
DrupalSib
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Forms
drubb
 
D8 Form api
D8 Form apiD8 Form api
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Fabien Potencier
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
Mariusz Kozłowski
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
Michelangelo van Dam
 
Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)
Arnaud Langlade
 
Symfony CoP: Form component
Symfony CoP: Form componentSymfony CoP: Form component
Symfony CoP: Form component
Samuel ROZE
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
Lars Jankowfsky
 
Apostrophe
ApostropheApostrophe
Apostrophe
tompunk
 
Wykorzystanie form request przy implementacji API w Laravelu
Wykorzystanie form request przy implementacji API w LaraveluWykorzystanie form request przy implementacji API w Laravelu
Wykorzystanie form request przy implementacji API w Laravelu
Laravel Poland MeetUp
 
Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu
Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w LaraveluLaravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu
Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu
HighSolutions Sp. z o.o.
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
Jonathan Wage
 
Crafting beautiful software
Crafting beautiful softwareCrafting beautiful software
Crafting beautiful software
Jorn Oomen
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf Conference
 
Everything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to askEverything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to ask
Andrea Giuliano
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
Daniel Knell
 
Models Best Practices (ZF MVC)
Models Best Practices (ZF MVC)Models Best Practices (ZF MVC)
Models Best Practices (ZF MVC)eddiejaoude
 

Similar to Mikhail Kraynuk. Form api. Drupal 8 (20)

Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAXМихаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Forms
 
D8 Form api
D8 Form apiD8 Form api
D8 Form api
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
 
Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)
 
Symfony CoP: Form component
Symfony CoP: Form componentSymfony CoP: Form component
Symfony CoP: Form component
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
Apostrophe
ApostropheApostrophe
Apostrophe
 
Wykorzystanie form request przy implementacji API w Laravelu
Wykorzystanie form request przy implementacji API w LaraveluWykorzystanie form request przy implementacji API w Laravelu
Wykorzystanie form request przy implementacji API w Laravelu
 
Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu
Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w LaraveluLaravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu
Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu
 
Migrare da symfony 1 a Symfony2
 Migrare da symfony 1 a Symfony2  Migrare da symfony 1 a Symfony2
Migrare da symfony 1 a Symfony2
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Crafting beautiful software
Crafting beautiful softwareCrafting beautiful software
Crafting beautiful software
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
 
Everything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to askEverything you always wanted to know about forms* *but were afraid to ask
Everything you always wanted to know about forms* *but were afraid to ask
 
The new form framework
The new form frameworkThe new form framework
The new form framework
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
 
Models Best Practices (ZF MVC)
Models Best Practices (ZF MVC)Models Best Practices (ZF MVC)
Models Best Practices (ZF MVC)
 

More from i20 Group

Александр Воинов. Power of Drupal market
Александр Воинов. Power of Drupal marketАлександр Воинов. Power of Drupal market
Александр Воинов. Power of Drupal market
i20 Group
 
Журавлёв Артем. Современные инструменты отдела продаж
Журавлёв Артем. Современные инструменты отдела продажЖуравлёв Артем. Современные инструменты отдела продаж
Журавлёв Артем. Современные инструменты отдела продаж
i20 Group
 
Рогаченко Ксения. Инструменты онлайн маркетинга в b2b сегменте
Рогаченко Ксения. Инструменты онлайн маркетинга в b2b сегментеРогаченко Ксения. Инструменты онлайн маркетинга в b2b сегменте
Рогаченко Ксения. Инструменты онлайн маркетинга в b2b сегменте
i20 Group
 
Александр Войнов. Digital охота
Александр Войнов. Digital охотаАлександр Войнов. Digital охота
Александр Войнов. Digital охота
i20 Group
 
Осипенко Константин. Как привлечь новых клиентов на падающем рынке
Осипенко Константин. Как привлечь новых клиентов на падающем рынкеОсипенко Константин. Как привлечь новых клиентов на падающем рынке
Осипенко Константин. Как привлечь новых клиентов на падающем рынке
i20 Group
 
Горина Екатерина. 4 простых правила дизайна для увеличения конверсии
Горина Екатерина. 4 простых правила дизайна для увеличения конверсииГорина Екатерина. 4 простых правила дизайна для увеличения конверсии
Горина Екатерина. 4 простых правила дизайна для увеличения конверсии
i20 Group
 
Eugene Ilyin. Why Drupal is cool?
Eugene Ilyin. Why Drupal is cool? Eugene Ilyin. Why Drupal is cool?
Eugene Ilyin. Why Drupal is cool?
i20 Group
 
Anton Shloma. Drupal as an integration platform
Anton Shloma. Drupal as an integration platformAnton Shloma. Drupal as an integration platform
Anton Shloma. Drupal as an integration platform
i20 Group
 
Виджет amoCRM. Инструкция
Виджет amoCRM. ИнструкцияВиджет amoCRM. Инструкция
Виджет amoCRM. Инструкция
i20 Group
 
Pavel Ruban. High loaded PHP operations over web interface
Pavel Ruban. High loaded PHP operations over web interfacePavel Ruban. High loaded PHP operations over web interface
Pavel Ruban. High loaded PHP operations over web interface
i20 Group
 
Grigoriy Shlyapkin. Drupal. First steps
Grigoriy Shlyapkin. Drupal. First stepsGrigoriy Shlyapkin. Drupal. First steps
Grigoriy Shlyapkin. Drupal. First steps
i20 Group
 
Scrum lego game instructuons
Scrum lego game instructuonsScrum lego game instructuons
Scrum lego game instructuons
i20 Group
 
Pavel Prischepa. Wodby
Pavel Prischepa. WodbyPavel Prischepa. Wodby
Pavel Prischepa. Wodby
i20 Group
 
Sergey Cherebedov. Interesting Drupal Distributions
Sergey Cherebedov. Interesting Drupal DistributionsSergey Cherebedov. Interesting Drupal Distributions
Sergey Cherebedov. Interesting Drupal Distributions
i20 Group
 
Namzhilma Zhambalova. Ajax pane. lazy pane.
Namzhilma Zhambalova. Ajax pane. lazy pane.Namzhilma Zhambalova. Ajax pane. lazy pane.
Namzhilma Zhambalova. Ajax pane. lazy pane.
i20 Group
 
Sergey Susikov. Virtualzation. My rakes
Sergey Susikov. Virtualzation. My rakesSergey Susikov. Virtualzation. My rakes
Sergey Susikov. Virtualzation. My rakes
i20 Group
 
Olesya Prokopenko.FlexBox. Future of the slicing
Olesya Prokopenko.FlexBox. Future of the slicingOlesya Prokopenko.FlexBox. Future of the slicing
Olesya Prokopenko.FlexBox. Future of the slicing
i20 Group
 
Chingis Sandanov. Container virtualization
Chingis Sandanov. Container virtualizationChingis Sandanov. Container virtualization
Chingis Sandanov. Container virtualization
i20 Group
 
Artem Zigar. Development Tools. Readability of a code
Artem Zigar. Development Tools. Readability of a codeArtem Zigar. Development Tools. Readability of a code
Artem Zigar. Development Tools. Readability of a code
i20 Group
 
Alexander Taranov. Right slicing for drupal = painless teming
Alexander Taranov. Right slicing for drupal = painless temingAlexander Taranov. Right slicing for drupal = painless teming
Alexander Taranov. Right slicing for drupal = painless temingi20 Group
 

More from i20 Group (20)

Александр Воинов. Power of Drupal market
Александр Воинов. Power of Drupal marketАлександр Воинов. Power of Drupal market
Александр Воинов. Power of Drupal market
 
Журавлёв Артем. Современные инструменты отдела продаж
Журавлёв Артем. Современные инструменты отдела продажЖуравлёв Артем. Современные инструменты отдела продаж
Журавлёв Артем. Современные инструменты отдела продаж
 
Рогаченко Ксения. Инструменты онлайн маркетинга в b2b сегменте
Рогаченко Ксения. Инструменты онлайн маркетинга в b2b сегментеРогаченко Ксения. Инструменты онлайн маркетинга в b2b сегменте
Рогаченко Ксения. Инструменты онлайн маркетинга в b2b сегменте
 
Александр Войнов. Digital охота
Александр Войнов. Digital охотаАлександр Войнов. Digital охота
Александр Войнов. Digital охота
 
Осипенко Константин. Как привлечь новых клиентов на падающем рынке
Осипенко Константин. Как привлечь новых клиентов на падающем рынкеОсипенко Константин. Как привлечь новых клиентов на падающем рынке
Осипенко Константин. Как привлечь новых клиентов на падающем рынке
 
Горина Екатерина. 4 простых правила дизайна для увеличения конверсии
Горина Екатерина. 4 простых правила дизайна для увеличения конверсииГорина Екатерина. 4 простых правила дизайна для увеличения конверсии
Горина Екатерина. 4 простых правила дизайна для увеличения конверсии
 
Eugene Ilyin. Why Drupal is cool?
Eugene Ilyin. Why Drupal is cool? Eugene Ilyin. Why Drupal is cool?
Eugene Ilyin. Why Drupal is cool?
 
Anton Shloma. Drupal as an integration platform
Anton Shloma. Drupal as an integration platformAnton Shloma. Drupal as an integration platform
Anton Shloma. Drupal as an integration platform
 
Виджет amoCRM. Инструкция
Виджет amoCRM. ИнструкцияВиджет amoCRM. Инструкция
Виджет amoCRM. Инструкция
 
Pavel Ruban. High loaded PHP operations over web interface
Pavel Ruban. High loaded PHP operations over web interfacePavel Ruban. High loaded PHP operations over web interface
Pavel Ruban. High loaded PHP operations over web interface
 
Grigoriy Shlyapkin. Drupal. First steps
Grigoriy Shlyapkin. Drupal. First stepsGrigoriy Shlyapkin. Drupal. First steps
Grigoriy Shlyapkin. Drupal. First steps
 
Scrum lego game instructuons
Scrum lego game instructuonsScrum lego game instructuons
Scrum lego game instructuons
 
Pavel Prischepa. Wodby
Pavel Prischepa. WodbyPavel Prischepa. Wodby
Pavel Prischepa. Wodby
 
Sergey Cherebedov. Interesting Drupal Distributions
Sergey Cherebedov. Interesting Drupal DistributionsSergey Cherebedov. Interesting Drupal Distributions
Sergey Cherebedov. Interesting Drupal Distributions
 
Namzhilma Zhambalova. Ajax pane. lazy pane.
Namzhilma Zhambalova. Ajax pane. lazy pane.Namzhilma Zhambalova. Ajax pane. lazy pane.
Namzhilma Zhambalova. Ajax pane. lazy pane.
 
Sergey Susikov. Virtualzation. My rakes
Sergey Susikov. Virtualzation. My rakesSergey Susikov. Virtualzation. My rakes
Sergey Susikov. Virtualzation. My rakes
 
Olesya Prokopenko.FlexBox. Future of the slicing
Olesya Prokopenko.FlexBox. Future of the slicingOlesya Prokopenko.FlexBox. Future of the slicing
Olesya Prokopenko.FlexBox. Future of the slicing
 
Chingis Sandanov. Container virtualization
Chingis Sandanov. Container virtualizationChingis Sandanov. Container virtualization
Chingis Sandanov. Container virtualization
 
Artem Zigar. Development Tools. Readability of a code
Artem Zigar. Development Tools. Readability of a codeArtem Zigar. Development Tools. Readability of a code
Artem Zigar. Development Tools. Readability of a code
 
Alexander Taranov. Right slicing for drupal = painless teming
Alexander Taranov. Right slicing for drupal = painless temingAlexander Taranov. Right slicing for drupal = painless teming
Alexander Taranov. Right slicing for drupal = painless teming
 

Recently uploaded

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 

Recently uploaded (20)

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 

Mikhail Kraynuk. Form api. Drupal 8

  • 1. Form API – Drupal 8 Крайнюк Михаил
  • 2. Drupal 8 – объектно-ориентирован. Form API теперь тоже…
  • 3. <?php /** * @file * Contains DrupalExampleFormExampleForm. */ namespace DrupalexampleForm; use DrupalCoreFormFormInterface; /** * Provides a simple example form. */ class ExampleForm implements FormInterface { } public function getFormID() public function buildForm(array $form, array &$form_state) public function validateForm(array &$form, array &$form_state) public function submitForm(array &$form, array &$form_state)
  • 4. public function buildForm(array $form, array &$form_state) { $form['my_text_field'] = array( '#type' => 'textfield', '#title' => 'Example', ); return $form; } Form Builder
  • 5. public function validateForm(array $form, FormStateInterface &$form_state) { if (strlen($form_state->getValue('phone_number')) < 3) { $form_state->setErrorByName('phone_number', $this->t('The phone number is too short.')); } } Form Validate
  • 6. use DrupalsystemSystemConfigFormBase; class ExampleConfigForm extends SystemConfigFormBase { /** * Implements DrupalCoreFormFormInterface::getFormID(). */ public function getFormID() { return 'example_systemconfigformbase'; } /** * Implements DrupalCoreFormFormInterface::buildForm(). */ public function buildForm(array $form, array &$form_state) { $form = parent::buildForm($form, $form_state); // Use the Form API to define form elements. return $form; } … system_settings_form()