How to limit text length of text product option

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
nowrap
Posts: 37
Joined: 01 Mar 2023, 23:03

How to limit text length of text product option

Post by nowrap » 08 Jun 2023, 09:36

Hello,

we configured our voucher selection product to have a text type option.

If i am right the rendering is done in this file:
templates/client/html/common/partials/attribute.php

And the resulting input-Field is this:

Code: Select all

<input id="select-<?= $enc->attr( $key ) ?>" class="form-control" type="text" name="<?= $enc->attr( $this->formparam( ['b_prod', 0, 'attrcustid', $id] ) ) ?>">
Is it possible to limit the length of the text somehow?

Regards
nowrap

User avatar
aimeos
Administrator
Posts: 7915
Joined: 01 Jan 1970, 00:00

Re: How to limit text length of text product option

Post by aimeos » 10 Jun 2023, 06:20

Add a "maxlength" attribute to the input field in the template:
https://developer.mozilla.org/en-US/doc ... /maxlength
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

nowrap
Posts: 37
Joined: 01 Mar 2023, 23:03

Re: How to limit text length of text product option

Post by nowrap » 12 Jun 2023, 15:24

I know this attribute. Maybe my question wasn't precise enough.

I hoped, that aimeos had some kind of built-in mechanismn to limit input fields and present a counter on the field.
So that it is just a configuration.

We created a small javascript function for this now as a quick solution - adding the maxlength attribute to the html input, counting chars on keyup-event and changing the label field for the input.

Post Reply