Drupal 8 Development Cookbook - Second Edition: Harness the power of Drupal 8 with this recipe-based practical guide by Glaman Matt
Author:Glaman, Matt [Glaman, Matt]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2017-09-26T04:00:00+00:00
Adding additional submit handlers
Using a form alter hook, we can add additional submit handlers to a form. The proper way to do this is to load the current submit handlers, add the new one to the array, and reset the validators in the form state:
$submit_handlers = $form_state->getSubmitHandlers(); $submit_handlers[] = 'mymodule_form_submit'; $form_state->setSubmitHandlers($submit_handlers );
First, we will receive all of the currently set submit handlers from the form state as the $submit_handlers variable. We then append a new callback to the end of the array.
Once the $submit_handlers variable has been modified, we will override the form state's submit handler array by executing the setSubmitHandlers method.
You can also use PHP array manipulation functions to add your callback in different execution orders. For example, array_unshift will place your callback at the beginning of the array so that it can run first.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7778)
Grails in Action by Glen Smith Peter Ledbrook(7696)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6413)
Kotlin in Action by Dmitry Jemerov(5062)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3785)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3327)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(3085)
Mastering Bitcoin: Programming the Open Blockchain by Andreas M. Antonopoulos(2867)
The Art Of Deception by Kevin Mitnick(2604)
Drugs Unlimited by Mike Power(2467)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2311)
The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution by Walter Isaacson(2297)
Writing for the Web: Creating Compelling Web Content Using Words, Pictures and Sound (Eva Spring's Library) by Lynda Felder(2261)
SEO 2018: Learn search engine optimization with smart internet marketing strategies by Adam Clarke(2190)
A Blueprint for Production-Ready Web Applications: Leverage industry best practices to create complete web apps with Python, TypeScript, and AWS by Dr. Philip Jones(2142)
JavaScript by Example by S Dani Akash(2135)
DarkMarket by Misha Glenny(2083)
Wireless Hacking 101 by Karina Astudillo(2075)
Full-Stack React Projects by Shama Hoque(1990)
