This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

chandler2510
chandler2510

I have plugin to generate forms and use for validation. I have a very long form and there is one validation input and I exceed max-length of 255 characters that I think October puts on all input text fields. I need to figure out how to override or fix.

EDIT: I ended up just editing October's core and removing all instances. I think this would be nice if removed for the next release.

Last updated

Daniel81
Daniel81

You'll need to either create an Issue or Pull Request over on Github for this change to be considered in the core: https://github.com/octobercms/october

chandler2510
chandler2510

I had someone respond on IRC that the plugin should change the field to a textarea instead of text. I just didnt know how to do that because it isnt my plugin.

aqw137
aqw137

quick solution: change partial for text field; ...../modules/backend/widgets/form/partials/_field_text.htm

maxlength="255"

change to

    maxlength="<?= isset($field->config['maxlength']) ? $field->config['maxlength'] : 255 ?>"

and then if you have in your fields.yaml this:

  maxlength: 2

it will work

Flynsarmy
Flynsarmy

aqw137 said: quick solution...

This will be overwritten every october update. Your options at the moment are to

  1. write a custom form field
  2. add an issue to the october git repo
  3. send a PR to fix it.

If you choose to send a PR, don't use aqw137's approach above. October already supports an 'attributes' option. It would be weird to have one random attribute not using it when all the others do.

autumn
autumn

In case someone stumbles upon this, you can now overwrite the maxlength attribute in the fields config.

example

myfield:
    label: "My Field"
    type: text
    attributes:
        maxlength: '1000'

Last updated

1-6 of 6

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.