PhillippOhlandt / bolt-extension-user-profiles

Extend the default Bolt users based on your needs and create public profile pages
7 stars 3 forks source link

Uncaught Exception: Twig_Error_Runtime with bolt 3.2.5 #5

Open Pierre-RA opened 7 years ago

Pierre-RA commented 7 years ago

With bolt 3.2.5, when accessing the page /bolt/profile I get this error:

Twig_Error_Runtime in Template.php line 230: An exception has been thrown during the rendering of a template ("Calling "attr" on template "@bolt/_macro/_macro.twig" from template "field_textarea.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.") in "@bolt/edituser/edituser.twig" at line 53.

When I remove the line in question, I still get the error for the file field_text.twig. It seems that calling macro.attr(attr_text) is generating the error.

Any ideas?

PhillippOhlandt commented 7 years ago

Hey,

let me check that tonight! There might be some changes in Bolt 3.2.x that broke this.

Phillipp

Pierre-RA commented 7 years ago

Alright, thank you!

christophermh44 commented 7 years ago

+1 any news about this extension?

PhillippOhlandt commented 7 years ago

@christophermh44 Sorry, I completely forgot it. too much to do recently. Will have a look at it soon.

crim3hound commented 7 years ago

I am running Bolt 3.2.13, and I fixed this runtime error by calling "attribute" instead of "attr" in the extended profile templates.

Go to extensions/ohlandt/user-profiles/templates and in the field templates change macro.attr(attr_text), macro.attr(attr_opt) and macro.attr(attr_checkbox) to macro.attribute(attr_text) for text, macro.attribute(attr_opt) for select, and macro.attribute(attr_checkbox) for checkbox fields respectively.

I hope this helps. @PhillippOhlandt I hope you finally get to fix this in the extension.

cc: @christophermh44, @Pierre-RA

crim3hound commented 7 years ago

@PhillippOhlandt please check open PR.

UPDATE: The above edits fix this issue, but a new one seems to emerge. The attributes don't seem to be generated for respective input fields, but I'm thinking "attribute" is the correct function for the same. See https://twig.symfony.com/doc/2.x/functions/attribute.html

Any ideas?

christophermh44 commented 7 years ago

Thanks :)

crim3hound commented 7 years ago

You're welcome @christophermh44. I realised however that my solution from before was a bit rash and messed up with the dynamic attributes and database writes.

What you need to do is add {% from '@bolt/_macro/_macro.twig' import attr %} to the top of each of the four input field templates, then find all instances of {{ macro.attr(attr_text) }}, {{ macro.attr(attr_opt) }} and {{ macro.attr(attr_checkbox) }} and delete the macro. from the twig function. Leave everything else as it is.

This works for me, and I hope this works for anyone else who encounters the error.

UPDATE: I have made the necessary edits to my pull requests, which are available to merge. Feel free to review the code.

cc: @PhillippOhlandt