Page 1 of 1

Value of config field "hidden"

Posted: Thu Sep 18, 2008 11:02 pm
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

Re: Value of config field "hidden"

Posted: Fri Sep 19, 2008 11:17 am
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

Posted: Mon Sep 22, 2008 1:18 am
by WebComPas
OK, thanks a lot. After changing my PHP code, it works as it should.

Regards,
Pascal

Re: Value of config field "hidden"

Posted: Sat Nov 29, 2014 11:01 am
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">