Project

General

Profile

Actions

Task #69396

closed

Forms: validation of SELECT element

Added by Björn Jacob over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2015-08-28
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Originally reported in #45605.

Mandatory for select-boxes: this validation ALWAYS succeeds because it is not possible to add an empty select-option.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #45605: Forms: Optimize and fix certain validation rulesClosed2013-02-19

Actions
Actions #1

Updated by Björn Jacob over 8 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

This can be achieved easily using e.g. the alphabetic validator. See the following example:


enctype = multipart/form-data
method = post
prefix = tx_form
confirmation = 1
prefix = formPid7
class = formPid7

10 = SELECT
10 {
    label = Select
    name = select

    10 = OPTION
    10 {
        data =
    }

    20 = OPTION
    20 {
        data = Mr
        value = Mr
    }

    30 = OPTION
    30 {
        data = Mrs
        value = Mrs
    }
}

20 = SUBMIT
20 {
    name = submit
}

rules {
    1 = alphabetic
    1 {
        element = select
        message = This field is mandatory.
        error = Please choose an option.
    }
}

Actions #2

Updated by Björn Jacob over 8 years ago

  • Tracker changed from Bug to Task
Actions

Also available in: Atom PDF