I'm trying to update an extension from 1.5 to 1.7 and I spend several hours trying to figure out why my select list has the right amount of options, but they all miss the text label...

 

Digging into the code I ended up in the JHtmlSelect::options() function. the line that screws my list is 624:

 

($options['option.text.toHtml'] ? htmlentities(html_entity_decode($text), ENT_COMPAT, 'UTF-8') : $text)

 

now $options is self::$_optionDefaults['option'] . Line 624 should actually be transformed to

just:

htmlentities(html_entity_decode($text), ENT_COMPAT, 'UTF-8'), because it doesn't seem like you have any choice there, do you? I can't find a way to override the default options... which means that we always end with option.text.toHtml = true... Or am I completely wrong?

 

And just wondering - am I the only one who things that the code in j1.6 and j1.7 has gotten really hard to read and understand?

Tags: 1.7, jhtmlselect, joomla

Views: 87

Replies to This Discussion

I had the opportunity to do some training for Joomla developers a few weeks ago. They wanted training in Joomla! 1.5, not 1.6. I must admit, I was reminded at how fun and simple it was using 1.5.

JForm in particular seems to have created a lot of duplication of work and it's not clear to me where filtering and validation and data element typing should be placed. JTable was simple - and it's still required but it doesn't work exactly the same and it appears to do much of what JForm does.

The other factor is the layers and layers of abstraction. That should be completed and simplified so devs understand what is automatically provided and how to override.

Anyway, 1.6 is still new to us, but after working with 1.6 for well over a year and going back to 1.5 for this training, I must agree, 1.5 was easier to use and understand.

Hi Daniel

 

Infact, the framework allows you to override the option 'option.text.toHtml' (and any other options) , but Yes, it is difficult and you really need to read code to understand how to override these options . Here is the code I used in my component (which override 'option.text.toHtml' option) :

 

$lists['category_id'] = JHtml::_('select.genericlist', $options, 'category_id[]', array(
'option.text.toHtml' => false ,
'list.attr' => 'class="inputbox" size="5" multiple="multiple" ',
'option.text' => 'text' ,
'option.key' => 'value',
'list.select' => $itemCategories,
)) ;

 

Some notes :

- The function call need to have exactly 3 parametters as in the sample code .

- The final parametters is an array and you can override any options you want (For example, option.text.toHtml true by default and I set it to false in this example to make it works with my component) .

 

Hope this help !

 

 

Hey Tuan,

Actually I did the same this morning and I was not able to override option.text.toHtml... Now that you are saying that it is working, I'll try it again.

Thanks,

Daniel

Ok, as usual it is the user!!!! I'm sorry for stating that those options are not usable. I know what I did wrong this morning! Instead of providing a second param = name, I provided 2 params and because my first parameter was correct, I got a select list and just thought that I can't override the parameters.If anyone felt offended by my false statement above - I'm sorry, please don't take it personally :)

 

But I stay behind my words - joomla 1.6, j1.7 are not easy to read. I know that this has to do with complexity, but reading the code in nooku is like reading "the Hitchhiker's guide to the Galaxy"(not easy but fun) and reading the joomla code is like reading a boring study book... (and I never felt this way with j1.5)

Hehe, no worry Daniel . Infact, I thought the same with you at the beginning and only found out it is possible to override the options recently :).

HOLY MOTHER! I just spent more than 3 hours trying to fix this &^%@#@. Traced the codes, finally found the keyword "option.text.toHtml", googled it, found this thread, and BAM!

 

THANKS GUYS! I ALMOST TORE MY HAIR OUT!

 

And yes, 1.6/1.7's codes are a lot harder to trace compared to 1.5.

RSS

Badge

Loading…

© 2012   Created by Amy Stephen.

Badges  |  Report an Issue  |  Terms of Service