Forum

Thread tagged as: Problem

Tag attribute default resets to default value when saved empty

Hi guys,

(I'm new to perch and this forum so please bear with me if I'm not doing everything right)

My problem in steps:

  • I'm using the tag attribute "default" in a perch:content type="text" field

  • default value shows upon creation: works as expected

  • deleting default value, texfield empty, save, no value shows up in the HTML-Output: works as expected

  • reload the admin page, default value shows up again: not working as expected, textfield has to stay empty

How do I make the empty field stay empty (still using a default value)?

Thanks for your help!

Template Code Snippet:

<perch:content id="alt" type="text" default="Bildunterschrift" label="Bildunterschrift" />

Diagnostics:

Perch: 2.8.15, PHP: 5.6.2, MySQL: 5.1.61, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.15), assets (2.8.15), categories (2.8.15)
App runtimes: <?php $apps_list = array( 'content', 'categories', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /xxxxxxxxxxx/xxxxxxxx/htdocs/perch
PERCH_CORE: /xxxxxxxxxxx/xxxxxxxx/htdocs/perch/core
PERCH_RESFILEPATH: /xxxxxxxxxxx/xxxxxxxx/htdocs/perch/resources
Image manipulation: GD
PHP limits: Max upload 8M, Max POST 8M, Memory: 128M, Total max file upload: 8M
Resource folder writeable: Yes
HTTP_HOST: xxxxxxxxxxx
DOCUMENT_ROOT: /xxxxxxxxxxx/xxxxxxxx/htdocs
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Jochen R.

Jochen R. 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What is the aim of the default value in this case? It is designed to be the default for an empty field.

If you want an alternative if the field is empty, you can do that in your template.

The aim is to prefill the field for editors. E.g. with a copyright sign. Or to have a whole block as boilerplate. Many other cases come to mind.

I want the empty field to stay empty if I clear the default value. I could understand the default value coming back if the field was marked required or something like that. But if I save the field empty intentionally, it should stay that way.

Is there a way to achieve that? Thanks for the support.

Drew McLellan

Drew McLellan 2638 points
Perch Support

We don't currently distinguish between never completed and empty - HTTP and browsers collude to make that quite tricky.

Thanks, good to know.