Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by PhpStorm.
- * User: sony
- * Date: 28/02/2016
- * Time: 23:23
- */
- /**
- * @file
- * Contains Drupalcontact_formFormContributeForm.
- */
- namespace Drupalcontact_formForm;
- use DrupalCoreFormFormBase;
- use DrupalCoreFormFormStateInterface;
- use DrupalComponentUtilityUrlHelper;
- /**
- * Contribute form.
- */
- class ContributeForm extends FormBase {
- /**
- * {@inheritdoc}
- */
- public function getFormId() {
- return 'contact_form_contribute_form';
- }
- /**
- * {@inheritdoc}
- */
- public function buildForm(array $form, FormStateInterface $form_state) {
- $form['Full Name'] = array(
- '#type' => 'textfield',
- '#title' => t('Full Name'),
- '#required' => TRUE,
- );
- $form['E-mail'] = array(
- '#type' => 'email',
- '#title' => t('E-mail'),
- );
- $form['Type of feedback'] = array(
- '#type' => 'radios',
- '#title' => t('Feedback'),
- '#description' => t('Type of feedback'),
- '#options' => array(
- t('Comments or suggestions'),
- t('Questions'),
- t('Report a problem(s)'),
- t('Other'),
- )
- );
- $form['Subject'] = array(
- '#type' => 'textfield',
- '#title' => t('Subject'),
- );
- $form['Your Message'] = array(
- '#type' => 'textarea',
- '#title' => t('Your Message'),
- );
- $form['my_captcha_element'] = array(
- '#type' => 'captcha',
- '#captcha_type' => 'Image',
- );
- $form['sendt'] = array(
- '#type' => 'submit',
- '#value' => t('Send'),
- );
- return $form;
- }
- /**
- * {@inheritdoc}
- */
- public function validateForm(array &$form, FormStateInterface $form_state) {
- if (!UrlHelper::isValid($form_state->getValue('video'), TRUE)) {
- $form_state->setErrorByName('video', $this->t("The video url '%url' is invalid.", array('%url' => $form_state->getValue('video'))));
- }
- }
- /**
- * {@inheritdoc}
- */
- public function submitForm(array &$form, FormStateInterface $form_state) {
- foreach ($form_state->getValues() as $key => $value) {
- drupal_set_message($key . ': ' . $value);
- }
- }
- $form['tabs']['upload']['captcha'] = [
- '#type' => 'captcha',
- '#captcha_type' => 'captcha/Math',
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement