Parameter not defaulting to 0

This forum is for reporting bugs in Joomla!. Please don't report problems with extensions in here.
Locked
User avatar
Alfred
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 142
Joined: Fri Aug 04, 2006 11:28 am
Contact:

Parameter not defaulting to 0

Post by Alfred » Mon Apr 27, 2009 8:20 pm

Hi,

Somehow I'm unable to set my parameter default the way I like..

In my 'component.xml' I have:

Code: Select all

<params>
   <param name="param1" default="0" />
   <param name="param2" default="1" />
</params>
In the config.xml I have:

Code: Select all

<param type="radio" name="param1" label="PARAM1" description="PARAM1_DESC" >
        <option value="0">No</option>
        <option value="1">Yes</option>
   </param>
   <param type="radio" name="param2" label="PARAM2" description="PARAM2_DESC" >
        <option value="0">No</option>
        <option value="1">Yes</option>
   </param>
This results in param1 both options being blank and param2 has YES preselected as default.
Apparently 0 is not accepted as default....

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7897
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Parameter not defaulting to 0

Post by mcsmom » Tue Apr 28, 2009 9:55 am

What do you mean by "both options being blank"? That seems to me a problem somewhere else, not the default setting. If you change the default to 1 does it work? That is the test of your theory.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
Alfred
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 142
Joined: Fri Aug 04, 2006 11:28 am
Contact:

Re: Parameter not defaulting to 0

Post by Alfred » Tue Apr 28, 2009 10:37 am

What do you mean by "both options being blank"?
With that I mean that neither radiobutton is activated, see screencapture from the parameters window.

Image

If you set the default to 1, YES is preselected, if you set it to 0, I expect NO to be preselected.
If I use 1 and 2 it also works as expected, but in my script working with values of 0 and 1 is easier....

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7897
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Parameter not defaulting to 0

Post by mcsmom » Tue Apr 28, 2009 11:03 am

Are you using firefox? What happens if you change browsers?


See
https://bugzilla.mozilla.org/show_bug.cgi?id=394782
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
Alfred
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 142
Joined: Fri Aug 04, 2006 11:28 am
Contact:

Re: Parameter not defaulting to 0

Post by Alfred » Tue Apr 28, 2009 11:53 am

mcsmom wrote:Are you using firefox? What happens if you change browsers?
Same result when using IE, also no changing of the radiobuttons when doing a refresh (which was the mentioned Mozilla bug)

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7897
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Parameter not defaulting to 0

Post by mcsmom » Tue Apr 28, 2009 12:37 pm

Where are you trying to get this? In the component or in the config? They are two different places. In the config.xml I would add the default this way:

<param name="show_link_hits" type="radio" default="0" label="Hits" description="TIPIFSETTOSHOWHITS">

If you look at the core components (like weblinks) they don't really put information like defaults in the component.xml file. It's really just the info for the components view in the extensions manager.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
Alfred
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 142
Joined: Fri Aug 04, 2006 11:28 am
Contact:

Re: Parameter not defaulting to 0

Post by Alfred » Tue Apr 28, 2009 12:50 pm

Well, the joomla docs tell a different story:
1. Component-wide default parameters

These can be created at installation of the Component, by including <param /> elements in the installation XML file (typically called COMPONENT_NAME.xml, and located in the root folder of the Component package. As far as the parameters are concerned, this XML file has the following structure:

<install>
...
<params>
<param />

<!-- Example: the following will create a line in the parameters field
reading 'font_size=100\n': -->
<param name="font_size" default="16" />

...
</params>
...
</install>

Each <param /> element must be given the attributes name and default, which define the parameter name and value respectively. These values are then copied to the jos_components table in the database.
it's not that it isn't working at all, but just that it won't accept a '0' as default....

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7018
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: Parameter not defaulting to 0

Post by AmyStephen » Tue Apr 28, 2009 1:16 pm

Hi Alfred -

How have you been?

Code: Select all

   <param type="radio" name="param2"  default="0" label="PARAM2" description="PARAM2_DESC" >
That's the only way I know of to add the default in your param statement.

Can you share a link to that document? I have not heard of that approach.
Amy :)

Edit - I saw the link. Not certain about that. I have not heard of that before. Interesting.

User avatar
Alfred
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 142
Joined: Fri Aug 04, 2006 11:28 am
Contact:

Re: Parameter not defaulting to 0

Post by Alfred » Tue Apr 28, 2009 1:33 pm

hi Amy,

I'm just fine (as always..) ;D

The approach as mentioned in the joomla docs work just fine, didn't notice anything until I wanted something to default to NO.

As a newbee developer the docs is all I can rely on...I thought...
I'll see about the other approach, but in that case the docs need to be changed to avoid the confusion.

Edit:
Well setting the default in the config.xml and leaving out the params in the component.xml has a drawback, the parmas are not saved to the jos_components table.....
I'll have to dig deeper...

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7897
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Parameter not defaulting to 0

Post by mcsmom » Tue Apr 28, 2009 8:11 pm

Well it does seem like a possible bug. We have mainly been looking at the core extensions, but of course they don't use component.xml since they are preinstalled and parameters are in the database.

Also, is it saving incorrectly when you install? Or is it just the display that is the problem?
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
Alfred
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 142
Joined: Fri Aug 04, 2006 11:28 am
Contact:

Re: Parameter not defaulting to 0

Post by Alfred » Wed Apr 29, 2009 2:53 pm

I changed to the before mentioned approach of defining the parameters and that works OK now.

Still I do think that the docs seem confusing on this point.

apparently I was not the only one confused:
http://forum.joomla.org/viewtopic.php?p=1595497

Thanks for the feedback


Locked

Return to “Joomla! 1.5 Bug Reporting”