[TYPO3-core] RFC #17680: Code cleanup: Remove obsolete checkbox code for input fields
Alexander Stehlik
alexander.stehlik at googlemail.com
Sun Feb 20 17:53:27 CET 2011
I just digged into this a bit an want to share the things I found out.
Maybe someone has good Ideas for this...
Abstract:
As the text below is quite long, here is a short abstract:
I like to change the behavior of the "required" evaluation. At the
moment, the value "0" is treated as an empty string witch it isn't.
Full story:
At the moment, there is an inconsistent behavior for the evaluation of
required integer fields. An example:
Database configuration:
width mediumint(11) unsigned DEFAULT '0' NOT NULL
Field configuration:
'width' => array(
'config' => array(
'type' => 'input',
'size' => '4',
'max' => '4',
'eval' => 'int,required',
'default' => 0,
),
),
When creating a new record, the field with will not be shown with an
exclamation mark because it is filled with 0. If I now replace the value
with something else and change it back to 0 it will not be accepted,
because 0 will be trimmed away to an empty string (in evalFunc_ltrim).
This can be correced by changing:
'default' => 0 to 'default' => '',
Now the field will be rendered with an exclamation mark from the start.
But what if you have a database record with different types, an the
field "with" is not visible in the default type? After changing the type
the record will be stored in the database, the field value is defaulting
to "0". The "width" field will be rendered without the exclamation mark.
The only solution for this is to change the type of the database field
to a varchar with an empty string as default value:
width varchar(30) DEFAULT '' NOT NULL
Now the field will be rendered with the yellow exclamation mark after
the type has changed.
I don't really like the workaround of storing integer values in varchar
field. There must be a better solution.
One that would make the most sense in my opinion is to change the
behavior of the evalFunc_ltrim when evaluating integer fields.
"required" should only check, if the field was set by the user. This is
also the case if it was set to 0. If you don't like 0 values, you can
still use the "range" configuration.
I'm looking forward to your input.
Kind regards,
Alex
Am 20.02.2011 14:39, schrieb Alexander Stehlik:
> This is an SVN patch request.
>
> Type: Code cleanup
>
> Bugtracker references:
> http://bugs.typo3.org/view.php?id=17680
>
> Branches:
> trunk
>
> Problem:
> Since version 4.5 the "checkbox" configuration for columns of type
> "input" is obsolete because every input field now has a clear button and
> date/time fields have a datepicker.
>
> Solution:
> Remove obsolete checkbox code and log use of deprecated configuration
> option.
>
> Kind regards,
> Alex
More information about the TYPO3-team-core
mailing list