Value of config field "hidden"

Creating and modifying plugins.
Post Reply
WebComPas
Regular
Posts: 101
Joined: Thu Nov 22, 2007 10:14 am
Contact:

Value of config field "hidden"

Post by WebComPas »

Hallo!

At the moment I'm developing a plugin. For this I wanted to use a config field of the type "hidden". It is defined like that:

Code: Select all

case 'lastUpdate':
                $propbag->add('type',        'hidden');
                $propbag->add('default',     '0');
                break;
Within the plugin configuration form it is (hidden) available, but with no default value. So the value is always empty.

Can anyone tell me, why this doesn't work like I want it to work?

Regards,
Pascal
Interessantes aus den Themenbereichen Computer, Internet und Programmierung unter http://www.it-blog.net
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Value of config field "hidden"

Post by garvinhicking »

Hi!

"0" translates as "empty" and thus is always empty. You should adjust your PHP code to accept an empty values as "0" as well.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
WebComPas
Regular
Posts: 101
Joined: Thu Nov 22, 2007 10:14 am
Contact:

Post by WebComPas »

OK, thanks a lot. After changing my PHP code, it works as it should.

Regards,
Pascal
Interessantes aus den Themenbereichen Computer, Internet und Programmierung unter http://www.it-blog.net
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Value of config field "hidden"

Post by Timbalu »

garvinhicking wrote:
The propbag type hidden does not set a default value. Why is this?
You must use $propbad->add('value') there. Since a hidden input cannot be changed, "default" makes no sense there.

Code: Select all

            case 'timestamp':
                $propbag->add('type', 'hidden');
                $propbag->add('value', time());
                break;
results in

Code: Select all

<input name="serendipity[plugin][timestamp]" type="hidden" value="1417098708">
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Post Reply