I added some custom fields to my panel users.
When I try to parse textarea fields to kirbytext it throws an error
<?= $u->bio()->kirbytext(); ?>
Fatal error: Call to a member function kirbytext() on string in /Applications/MAMP/htdocs/dkr2016/site/templates/wie.php on line 13
If I leave out the kirbytext() it works just fine but markdown isn’t converted into html (asterisks ** instead of displaying bold).
<?= kirbytext($u->bio()); ?>
Awesome, this works! Thank you!
Any particular reason why the other way does not work?
As the error message suggest,
$u->bio() returns just a string instead of an object. And you can’t use the field method on a string, but the kirbytext helper does accept a string.
I wonder what it would take to unify the capacity of field methods vs helpers. Is it even something to consider ?
The question is rather why a user field does not return the same kind of field object as a normal content field.
But I also wouldn’t mind being able to use $something['index]->kirbytext() instead of kirbytext($something[‘index’]). Is there any specific reason that comes to mind for the different behavior ?
Sorry if the topic is sliding away… I can take this discussion somewhere else.
A string is not an object.
->somemethod() is object notation for a non-static method. An object’s methods are defined in a class.