Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in 'number' type and 'text' type field with number validation #51

Open
xxtesaxx opened this issue May 3, 2018 · 0 comments
Open
Labels

Comments

@xxtesaxx
Copy link

xxtesaxx commented May 3, 2018

Problem Description

Not sure if there is any intention to make this work properly but in the old days, there was a number type field and also there is a number_validation option on text fields but neither of them seem to work at all in the Visual Builder and even on the backend side there are a few problems.

The settings I found in the core looked promising:

'number_validation' => true,
'value_type'        => 'int', //or 'float'
'value_min'         => 0,
'value_max'         => 100,
'default_on_front'  => '0',

When used, they have no effect though. Furthermore if 'number_validation' is turned on, you can only enter number of 0-100 in the BB and in the VB you can still enter characters.

I'd love to see a proper number field. Currently I mostly rely on range fields to enter numbers but this is not always a good solution. For example I have a number counter module and the user can enter any number but also letters as the field is a textfield.

Sure, I sanitize the field in my code but it would be more convenient if a user couldn't enter letters at all. A number field or a option on text fields to make sure the entered number is actually a number (int or float) would be great and it would be even better if it worked in the VB as well.

The problem with the range field is, that it is not obvious for the user that he can enter any number if desired, even if it's outside of the range of the slider. I'd really like to see a setting like this:

'a_number'   => array(
    'label'           => esc_html__( 'A number', 'et_builder' ),
    'description'     => esc_html__( 'Enter a number or leave empty to use the default value of 125', 'et_builder' ),
    'type'            => 'number',
    'default'         => 125,
    'value_type'      => 'int', //or 'float'
    'step'            => 25, //or 132.2
    'option_category' => 'basic_option',
    'toggle_slug'     => 'main_content',
),

Implementation shouldn't be to hard I believe. Its basically a range field but without the slider. I hope you understand what I mean. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants