XF 2.1 Template function max_length not working for custom entity

TiKu

Member
Hi,

My add-on defines an entity MyEntity with a field some_field:
Code:
        $structure->columns = [
            'some_field' => ['type' => self::STR, 'maxLength' => 250, 'required' => true]
        ];
The entity works fine, but I've noticed that I cannot use the specified maxLength in templates:
Code:
<xf:textboxrow name="allowed_value"
                label="{{phrase('some_value')}}"
                textbox-class="input--title"
                autofocus="autofocus"
                maxlength="{{max_length('My\AddOn:MyEntity', 'some_field')}}" />
The function max_length does not return anything. I've checked the entity's namespace a couple of times already, but don't see anything wrong. Am I using max_length wrong?
 
Hmm, this seems to work, thank you. But even in the included templates of xenForo I find code similar to mine. For instance in the template forum_post_thread:
maxlength="{{ max_length('XF:Thread', 'title') }}"
 
I can confirm that the max_length template function isn't working when passing in an entity short-name with a vendor namespace. XF:Entity works, but My\Addon:Entity doesn't. It's not matching properly against this regex /^\w+(?:\\\w+)?:\w+$/i, but I have no idea why as it looks like it should.
 
Top Bottom