1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

HTML digital character in dropdown element

Discussion in 'Community' started by georgie, Dec 3, 2018.

  1. georgie

    georgie Member

    Level: Community
    Hello Fabrik team and community!

    I plug Fabrik on a external DB, on which I can not handle myself.
    I generate a dropdown list from a table of this external DB (database join element).

    No problem, but just a display not very beautiful on values containing HTML digital character.
    example:
    Code (Text):
    ...'...
    It displays as is.

    Can Fabrik interpret these characters on the fly in my drop-down lists?

    THX

    Georges
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
    I think you can do it with "eval options" in "Advanced" (not tested)
    $opt->text = htmlspecialchars_decode($opt->text);
     
    georgie likes this.
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    I thought we already did that for dropdown items. Or maybe we only entity decoding?

    -- hugh
     
    georgie likes this.
  4. georgie

    georgie Member

    Level: Community
    Hello

    Thanks, but I can not handle this.
    I have tried:
    Code (Text):
    $opt->text = htmlspecialchars_decode($opt->text);
    Without success, no errors but no change.

    Georges
     
  5. troester

    troester Well-Known Member Staff Member

    Level: Community
    ok, ' ( = ') is special, you must use
    htmlspecialchars_decode($opt->text,ENT_QUOTES)

    You can also try
    html_entity_decode($opt->text,ENT_QUOTES)
     
    georgie likes this.
  6. georgie

    georgie Member

    Level: Community
    Ahhh, yes good!
    Indeed it works perfectly in my databasejoin elements.

    Please is there an equivalent for a field element, used in a filter list (with dropdown option)?
    I have tried some syntaxs, without success.

    Georges
     
  7. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    I've made some changes to the code that should handle this automatically, for both regular dropdown options (the one you are doing yourself at the moment), and for filters (for most element types).

    However, I'm not 100% sure I've gotten it right for all filter types. I've written some standard code that handles entities, tags and translation of options. There's some stuff we need to do for some filter types and not others. For example, we have to strip_tags() for dropdowns and multiselect, but not checkbox, etc. And I'm not quite sure why some of the existing code only does htmlspecialchars for dropdowns.

    Anyway ... if @georgie and @troester are happy to do some testing on various filter types and entities (quotes, <, >, &) and encoded entities (&quot;, &#39; etc) ... I'll go ahead and commit the changes. I've done some testing, and I'm reasonably sure I haven't made anything worse, lol.

    -- hugh
     
    georgie likes this.

Share This Page