Value of config field "hidden"

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

Value of config field "hidden"

Post by WebComPas » Thu Sep 18, 2008 11:02 pm

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

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Value of config field "hidden"

Post by garvinhicking » Fri Sep 19, 2008 11:17 am

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 11:14 am
Contact:

Post by WebComPas » Mon Sep 22, 2008 1:18 am

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

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Value of config field "hidden"

Post by Timbalu » Sat Nov 29, 2014 11:01 am

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