Skip to content
Menu
Open World News Open World News
  • Privacy Policy
Open World News Open World News

Category: News

Wikimedia Pages Wanting Audios

Posted on April 12, 2023 by Michael G
Wikimedia Pages Wanting Audios is a sub campaign under WikiSound Audio Speaks Campaign, an international Wikimedia Campaign that seek to improve Wikimedia Pages and Wikimedia movements at…

Opensource.com: 7 open source modules to make your website accessible

Posted on April 12, 2023 by Michael G
7 open source modules to make your website accessible
neerajskydiver
Wed, 04/12/2023 – 03:00

Use these Drupal modules to make your website accessible to everyone.

As website accessibility continues to be a growing concern, website owners and developers need to ensure that their websites comply with the Americans with Disabilities Act…

Opensource.com: 7 open source modules to make your website accessible

How to use Flipper for feature flags in Rails

Posted on April 12, 2023 by Michael G
Feature flags are used all across the tech industry to test code at scale; this article explores how to integrate them into your Ruby on Rails application using the Flipper gem.
https://www.honeybadger.io/blog/flipper-feature-flags-rails/

How to upgrade Red Hat Ansible Automation Platform

Posted on April 12, 2023 by Michael G

Consider the variables when planning and executing your AAP or Tower upgrade and learn what makes sense for your scenario. Read More at Enable Sysadmin

The post How to upgrade Red Hat Ansible Automation Platform appeared first on Linux.com.

Firefox rolls out Total Cookie Protection by default to more users worldwide

Posted on April 12, 2023 by Michael G

Take back your privacy Firefox is rolling out Total Cookie Protection by default to more Firefox users worldwide, making Firefox the most private and secure major browser available across Windows, Mac, Linux and Android. Total Cookie Protection is Firefox’s strongest privacy protection to date, confining cookies to the site where they were created, thus preventing […]

The post Firefox rolls out Total Cookie Protection by default to more users worldwide appeared first on The Mozilla Blog.

Nirmala Sitharaman’s Reply To Query On ‘Violence Against Muslims’ In India

Posted on April 11, 2023 by Michael G
Nirmala Sitharaman’s Reply To Query On ‘Violence Against Muslims’ In India.

Argus News is Odisha’s fastest-growing news channel having its presence on satellite TV and various web platforms. Watch the latest news updates LIVE on matters related to politics, sports, gadgets, business, entertainment, and more. Argus News is setting new standards for journalism through its differentiated programming, philosophy, and tagline ‘Satyara Sandhana’.

To stay updated on-the-go,

Visit Our Official Website: www.argusnews.in
iOS App: http://bit.ly/ArgusNewsiOSApp
Android App: http://bit.ly/ArgusNewsAndroidApp
Live TV: https://argusnews.in/live-tv/
Facebook: https://www.facebook.com/argusnews.in
YouTube:

/ theargusnewsodia
Twitter: https://twitter.com/ArgusNews_in
Instagram: https://www.instagram.com/argusnewsin

Argus News Is Available on:
TataPlay channel No – 1780
Airtel TV channel No – 609
Dish TV channel No – 1369
d2h channel No – 1757
SITI Networks – 18
Hathway – 732
GTPL KCBPL – 713
& other Leading Cable Networks please visit https://argusnews.in/channel_number for channel number list

You Can WhatsApp Us Your News On- 8480612900
#ArgusNews #ArgusEnglish #nirmalasitharaman #financeminister #violenceagainstmuslim #India

Quem os preparativos para o casamento atrapalharam? | Mil e Uma Noites – Episódio 27

Posted on April 11, 2023 by Michael G
Onur Aksal (Halit Ergenç) é um homem que não confia nas mulheres porque foi traído há muito tempo e porque quando era muito jovem, seu pai o abandonou junto com sua mãe para ir com outra mulher. Ele também é um homem que gosta de ler muito, seu livro favorito é o famoso romance árabe As Mil e Uma Noites. Ele é o proprietário da importante construtora Binyapi; onde trabalha Sherezade Evliyaoğlu (Bergüzar Korel), uma brilhante arquiteta que perde o marido, Ahmed Evliyaoğlu, em um acidente e fica sozinha com um filho pequeno de cinco anos chamado Kaan (Efe Çınar), que foi diagnosticado com leucemia. Chega o momento em que a doença de Kaan atinge um ponto crítico, exigindo um transplante urgente de medula óssea. Ele vai até o sogro dela, Burhan Evliyaoğlu (Metin Çekmez), para pedir o dinheiro que ele precisa para a operação, mas ele se recusa a dar a ele, porque ele nunca concordou que seu filho, Ahmed (Atilla Türkmen) , deveria se casar com ela. Ele também a considera responsável por sua morte e vive a partir desse momento negando seu neto. Porque seu sogro lhe disse que não, Scherezade não tem escolha a não ser pedir dinheiro a Binyapi, Onur diz que ele dá a ela com a condição de que ela passe uma noite com ele (isso ele faz para testá-la, pois de acordo com ele, as mulheres só estão interessadas em dinheiro).

Siga o canal

#MileUmaNoites #série turca #dublada em português

ICYMI, Kanebo opened their first stand-alone store here in PH. Here’s a quick tour of their store.

Posted on April 11, 2023 by Michael G
ICYMI, Kanebo opened their first stand-alone store here in PH. Here’s a quick tour of their store.

French Wikimedia Culture and Digital Day 2023

Posted on April 11, 2023 by Michael G
Wikimédia France is very pleased to share with you that the 4th edition of the Wikimedia Culture and Digital Day 2023 will take place on…

Specbee: Revitalize Your Forms: Enhancing User Experience with Drupal’s Form API

Posted on April 11, 2023 by Michael G
Revitalize Your Forms: Enhancing User Experience with Drupal’s Form API
Nitin Lama
11 Apr, 2023

Did you know “form fatigue” is a thing?! It’s a feeling of exhaustion when you have to fill out too many forms. But forms are an integral part of a website and no site owner can (or should) do without them. So how can you make sure your website helps reduce form fatigue? Easy! Keep it simple and short, offer clear and concise instructions, break up long forms, and use autofill. Most important of all, make sure you’re offering a breezy user experience to fill them out.

Drupal’s Form API offers a way to create easily customizable and themeable forms to blend well with any website. It provides developers with a set of functions and APIs to create, validate and process forms in Drupal. Take a deeper dive into the amazing Drupal Form API and find out how you can implement it in your next project.

Specbee: Revitalize Your Forms: Enhancing User Experience with Drupal's Form API

Why Form API

As you know, forms are a crucial part of every website because they allow users to interact with them by submitting data. Using Drupal’s Form API, developers can create unique forms for various purposes, including contact, login, and registration. A few reasons why you should consider Form API:

  1. It is easy to use and does not require much coding experience. You can create forms using a set of simple and intuitive functions.
  2. It provides built-in validation functions that allow you to validate form data easily. 
  3. Comes with built-in security features that help prevent attacks like cross-site scripting (XSS) and cross-site request forgery (CSRF).
  4. It is highly customizable and can be used to create complex forms with multiple fields, buttons, and actions.
  5. Form APIs are themeable, so developers can change CSS and HTML to make their forms look however they want.
  6. It can be easily integrated with other Drupal APIs.

Things you need to know before building forms

There are various kinds of forms that are often used in Drupal. Each contains a base class that you can extend in a unique module of your own design.

First, identify the type of form you need to build:

  • A generic form. Extend FormBase.
  • A configuration form that enables administrators to update a module’s settings. Extend ConfigFormBase.

Any form that has FormBase in its hierarchy must implement the following methods since FormBase implements FormInterface.

  • getFormId()
  • buildForm()
  • submitForm()

To create a generic custom form with the Form API, you’ll need to define a function that returns an array of form elements inside buildForm(). The key of each element is the name of the form element, and the value is an array of properties that define the element. For example, to create a text field, you would define an element like this:

$form['emp_name'] = [
     '#type' => 'textfield',
     '#title' => $this->t('Enter Name'),
     '#required' => TRUE,
];

Adding validation

Form API also provides a way to validate user input. You can add validation functions to your form definition that will be called when the form is submitted. If a validation function returns an error message, the form submission will be prevented and the error message will be displayed to the user.

To add a validation function, you will need to implement a validateForm().

Processing form submissions

When a form is submitted, Drupal calls a submission function that you define. The submission function can perform any necessary processing of the form data, such as saving it to the database

To define a submission function, you will need to implement a submitForm()

Integrate the form in a request

To integrate this form into a Drupal site’s URI structure, use a route like the following:

example.form:
  path: '/example-form'
  defaults:
    _title: 'Example form'
    _form: 'DrupalexampleFormExampleForm'
  requirements:
    _permission: 'access content'

The _form key tells the routing system that the provided class name is a form class to be instantiated and handled as a form.

Creating a custom form with Drupal Form API

Follow these easy step to begin the process of creating a custom form with Drupal’s Form API:

  1. Create a .info.yml inside a custom module. (As we are creating a separate module for custom forms, this step is not required for adding forms in an existing module).
  2. Create a form class for returning the form array. (custom_module/src/Form/Registration.php) 
  3. Create a .routing.yml file
  4. Create a .module and hook_form_alter() and/or hook_form_FORM_ID_alter() to alter the form (If needed).

Here is a complete example of an employee registration form:

Folder structure:

employee registration

 

1. employee_registration.info.yml

name: Employee Registration Form
type: module
description: Custom module for implementing custom employee registration form.
core_version_requirement: ^9 || ^10
package: Custom

2. src/Form/Registration.php

 'textfield',
     '#title' => $this->t('Enter Name'),
     '#required' => TRUE,
   ];

   $form['emp_no'] = [
     '#type' => 'textfield',
     '#title' => $this->t('Enter Employee Number'),
     '#required' => TRUE,
   ];

   $form['emp_mail'] = [
     '#type' => 'email',
     '#title' => $this->t('Enter Email ID'),
     '#required' => TRUE,
   ];

   $form['emp_phone'] = [
     '#type' => 'tel',
     '#title' => $this->t('Enter Contact Number'),
   ];

   $form['emp_dob'] = [
     '#type' => 'date',
     '#title' => $this->t('Enter DOB'),
     '#required' => TRUE,
   ];

   $form['emp_gender'] = [
     '#type' => 'select',
     '#title' => $this->t('Select Gender'),
     '#options' => [
       'Male' => $this->t('Male'),
       'Female' => $this->t('Female'),
       'Other' => $this->t('Other'),
     ],
   ];

    $form['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Save'),
      '#button_type' => 'primary',
    ];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    if (strlen($form_state->getValue('emp_phone')) setErrorByName('emp_phone', $this->t('The phone number is too short. Please enter a full phone number.'));
    }
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Processing form data.
    $this->messenger()->addMessage($this->t("Employee Registration Done!!"));
	   foreach ($form_state->getValues() as $key => $value) {
       $this->messenger()->addMessage($key . ': ' . $value);
    }
  }

}

3. employee_registration.routing.yml

employee_registration.form:
  path: '/registration-form'
  defaults:
    _title: 'Employee Registration'
    _form: 'Drupalemployee_registrationFormRegistration'
  requirements:
    _permission: 'access content'

Result:

employee registration form

 

emp reg result page

Final Thoughts

Form API lets you create complex and customized forms with validation and processing functions in Drupal. When you use Form API, you can be sure that your forms are consistent and easy to use for your users. Looking for a Drupal agency to help you build a user-friendly experience for your audience? Talk to our Drupal experts today!

Author: Nitin Lama

Meet Nitin Lama, a backend Drupal Developer at Specbee who believes progressing one day at a time could go a long way. Swimming is his hobby, but he’s a huge music lover and enjoys producing and exploring new music. Music and cooking act as therapy for him. Space and tech are his best conversation starters when meeting new people. If dreams came true, he’d be traveling to a Voyager station!

Drupal
Drupal Module
Drupal Development
Drupal Planet

 

Recent Blogs

Image
Drupal form API teaser

Revitalize Your Forms: Enhancing User Experience with Drupal’s Form API

Image
nitin passion story

Cheat Codes in Music – Nitin Lama’s Life in a Mirage

Image
Display modes teaser

Customizing Content Display in Drupal: A Guide to Display Modes

Want to extract the maximum out of Drupal?
TALK TO US

Featured Case Studies

Itsoc logo

IEEE Itsoc

Upgrading the web presence of IEEE Information Theory Society, the most trusted voice for advanced technology

Explore

Semi 252x91-01.png

Semi

A Drupal powered multi-site, multi-lingual platform to enable a unified user experience at SEMI

Explore

gsh logo

Great Southern Homes

Great Southern Homes, one of the fastest growing home builders in the US, sees greater results with Drupal

Explore

View all Case Studies

  • Previous
  • 1
  • …
  • 582
  • 583
  • 584
  • 585
  • 586
  • 587
  • 588
  • …
  • 821
  • Next

Recent Posts

  • SmartEsq has launched an AI-powered MFN Election tool
  • Open Source email Clients
  • When and how to use benchmarking
  • How Plotly AI revolutionizes the dashboard development process
  • [TUT] LoRa & LoRaWAN – MikroTik wAP LR8 kit mit The Things Network verbinden [4K | DE]

Categories

  • Android
  • Linux
  • News
  • Open Source
©2025 Open World News | Powered by Superb Themes
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT