Standard form field "range"

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
User avatar
zomtec
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Tue Jan 13, 2015 12:49 pm

Standard form field "range"

Post by zomtec » Sat Dec 05, 2015 4:06 pm

Since Joomla 3.2 there is a standard form field "range", that provides a horizontal scroll bar to specify a value in a range.
Within an extension's config file i inserted

Code: Select all

<field 
    name="range" 
    type="range" 
    default="1" 
    label="Range from 1 to 10 step 1" 
    description="" 
    min="1" 
    max="10" 
    step="1" />
and this is the result
Image
But i cannot see the current value.
How is it possible to show the value?
Last edited by zomtec on Sat Dec 12, 2015 9:09 am, edited 3 times in total.

User avatar
JLinker
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Mon Nov 19, 2007 2:29 pm
Contact:

Re: Standard form field "range"

Post by JLinker » Fri Dec 11, 2015 11:39 am

read this:
http://www.w3schools.com/jsref/prop_ran ... tvalue.asp

From what I understand, you'll have to use javascript to set a default value. Probably not Joomla's fault.
JLinker Facebook Tabs for Joomla, Virtuemart, Kunena, K2, JEvents, Hikashop, J2Store | JLinker Menu Generator | https://www.jlinker.com

User avatar
zomtec
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Tue Jan 13, 2015 12:49 pm

Re: Standard form field "range"

Post by zomtec » Fri Dec 11, 2015 1:19 pm

thank you.
i've found a solution by editing the core file
libraries/joomla/form/fields/range.php
from

Code: Select all

if i include php code, i get 403 error on saving
to

Code: Select all

---
But this will be lost next joomla update.
I hope, that one of the joomla developers will take a look at my changes and will implement the code, because a standard form field without knowing it's value is useless

User avatar
JLinker
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Mon Nov 19, 2007 2:29 pm
Contact:

Re: Standard form field "range"

Post by JLinker » Fri Dec 11, 2015 1:29 pm

strange, the link works for me.
here, you can test the input range:
http://www.w3schools.com/html/tryit.asp ... nput_range
add a value="somethig" attribute and it works.

here, explanation about how to get/set a default value with javascript:
http://www.w3schools.com/jsref/prop_ran ... tvalue.asp

I'm just saying that you should try using value="something" in your xml form rather that default="something" and see what happens.

If it doesn't work, try javascript to set the default value.
JLinker Facebook Tabs for Joomla, Virtuemart, Kunena, K2, JEvents, Hikashop, J2Store | JLinker Menu Generator | https://www.jlinker.com

User avatar
JLinker
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Mon Nov 19, 2007 2:29 pm
Contact:

Re: Standard form field "range"

Post by JLinker » Fri Dec 11, 2015 1:36 pm

hacking core is not a good idea. what will happen when you install other extensions using the same core range.php file? and as you said, changes will be lost after upgrade or update. Instead, you can copy the range.php into your /com_mycomponent/models/fields directory and customize it there for your component to use.

here is how to create a custom form field:
https://docs.joomla.org/Creating_a_cust ... ld_type/en

once you've done that for your range.php, you can do pretty much anything you want to the field. it will work with your xml form and you won't have to rape the core ;)
JLinker Facebook Tabs for Joomla, Virtuemart, Kunena, K2, JEvents, Hikashop, J2Store | JLinker Menu Generator | https://www.jlinker.com

User avatar
zomtec
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Tue Jan 13, 2015 12:49 pm

Re: Standard form field "range"

Post by zomtec » Fri Dec 11, 2015 1:47 pm

yes, but it is a joomla standard form field and it is useless without displaying the value.
i don't understand why i have to create a custum form field, because the standard one is not working. wouldn't it be better to fix the issue on a standard form field, so any other developer can use it without creating an own custum form field?

anyway

i cannot post the fixing solution for the range.php, because i always get 403 errors

User avatar
JLinker
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Mon Nov 19, 2007 2:29 pm
Contact:

Re: Standard form field "range"

Post by JLinker » Fri Dec 11, 2015 1:55 pm

i also got a 403 error when trying to post some javascript on the forum with the script tags.
it's very hard to find a bug in joomla and i'm not convinced (yet) that this is one. have you tried just using value="" instead of default='""
JLinker Facebook Tabs for Joomla, Virtuemart, Kunena, K2, JEvents, Hikashop, J2Store | JLinker Menu Generator | https://www.jlinker.com

User avatar
zomtec
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Tue Jan 13, 2015 12:49 pm

Re: Standard form field "range"

Post by zomtec » Fri Dec 11, 2015 5:24 pm

with my code changes the range field now looks like this
Image
Last edited by zomtec on Sat Dec 12, 2015 9:10 am, edited 1 time in total.

User avatar
JLinker
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Mon Nov 19, 2007 2:29 pm
Contact:

Re: Standard form field "range"

Post by JLinker » Fri Dec 11, 2015 9:11 pm

the links to your screenshots are broken, I can't see the picture. And I haven't seen the code, so I probably won't be able to explain an issue. Anyway if you're hacking the core, I won't be able to help you. Please try anything else but that. It's up to you.
JLinker Facebook Tabs for Joomla, Virtuemart, Kunena, K2, JEvents, Hikashop, J2Store | JLinker Menu Generator | https://www.jlinker.com


Locked

Return to “Joomla! 3.x Coding”