reduxframework / redux-framework

Redux is a simple, truly extensible options framework for WordPress themes and plugins!
http://redux.io
Other
1.74k stars 583 forks source link

Attribute not working with text field #3989

Closed j7-dev closed 9 months ago

j7-dev commented 9 months ago

Issue

attribute not working with text field.




Reproduce the issue

I followed the document here

Redux::set_field( 'redux_demo', 'SECTION_ID', array(
    'id'   => 'field_id',
    'type' => 'text',
    'attributes'       => array(
        'type'         => 'password',
        'readonly'     => 'readonly',
        'autocomplete' => 'off',
        'data-json' => array(
            'example' => 'json'
        )
    )
) );

But It seems not working 🔽

image




Expected result




Trace the source code

I trace code here redux-framework/redux-core/inc/fields/text/class-redux-text.php

I can't find any keyword with attributes in class-redux-text.php, it seems attributes key do NOTHING in class-redux-text.php

kprovance commented 9 months ago

The attributes feature was removed last year as it was designed for something we never used. You'll have to use the field arguments instead. I'll update the docs to get rid of all that old data.

j7-dev commented 9 months ago

Thank for reply.

So...if I want to use

<input type="password" />

<input type="number" min="0" max="10000" />

I have to extend these fields by using my custom extension right?

kprovance commented 9 months ago

Basically. Redux has a password field, but it doesn't have min or max. You could easily take that field and use it to make a custom extension. Be sure to change the class name so it doesn't conflict.

kprovance commented 9 months ago

Alternatively, if you're proficent in in it, you could use some custom JavaScript to add attributes to existing Redix fields. I've seen it done many times.