codekarim is just a bunch of reminders for fenuapps.com
resume/resume.info.yml
name: Resume description: A Resume form to enter user details. core: 8.x package: Custom type: module
resume/resume.routing.yml
resume.form: path: '/resume/myform' defaults: _title: 'Application form' _form: '\Drupal\resume\Form\ResumeForm' requirements: _permission: 'access content'
resume/src/Form/ResumeForm.php
'textfield', '#title' => t('Candidate Name:'), '#required' => TRUE, ); $form['candidate_mail'] = array( '#type' => 'email', '#title' => t('Email ID:'), '#required' => TRUE, ); $form['candidate_number'] = array ( '#type' => 'tel', '#title' => t('Mobile no'), ); $form['candidate_dob'] = array ( '#type' => 'date', '#title' => t('DOB'), '#required' => TRUE, ); $form['candidate_gender'] = array ( '#type' => 'select', '#title' => ('Gender'), '#options' => array( 'Female' => t('Female'), 'male' => t('Male'), ), ); $form['candidate_confirmation'] = array ( '#type' => 'radios', '#title' => ('Are you above 18 years old?'), '#options' => array( 'Yes' =>t('Yes'), 'No' =>t('No') ), ); $form['candidate_copy'] = array( '#type' => 'checkbox', '#title' => t('Send me a copy of the application.'), ); $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = array( '#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('candidate_number')) < 10) { $form_state->setErrorByName('candidate_number', $this->t('Mobile number is too short.')); } } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // drupal_set_message($this->t('@can_name ,Your application is being submitted!', array('@can_name' => $form_state->getValue('candidate_name')))); foreach ($form_state->getValues() as $key => $value) { drupal_set_message($key . ': ' . $value); } } }