Jump to content

Helper form attributes?


daveyrow

Recommended Posts

Hello, is it possile to set attributes to inputs in defining array? Like: 

array(
 'type' => 'text',
 'label' => $this->l('Path:'),
 'name' => 'path',
 'col' => 4,
 'class' => 'toggle_import_type toggle_item_xml',
 'attribute' => array(
  'readonly' => 'readonly',
  'data-custom' => 'whatever'
 )

)

with result of <input name="path" readonly="readonly" data-custom="whatever" etc....

 

it would be cool if it can, btw its not dificult to customize the helper, i can contribute if more people would like this thing

Edited by daveyrow (see edit history)
Link to comment
Share on other sites

  • 3 years later...

Hi from 2020!!

I'm searching this question's answer. I'm already examined all prestashop repository i can't get any result.

So, anyway I found a solution in the Prestashop sources. If you want to add a someting like data-products-url="/api/products" you  can't do this anyway with HelperForm class seems like  this class doesn't supports add custom attributes. You can store global javascript variable with your controller or module class if you want by using bellow code.

Media::addJsDef([
            'your_data_attribute' => "your_data",
        ]);

Why HelperForm doesn't support custom attributes?

  • Confused 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...