Forum

Thread tagged as: Error

Setting title="true" on a category or relationship field generates a PHP error.

Here's a template:

<perch:categories id="area" set="areas-geographical" label="Area" required="true" />
<perch:content id="parish_name" type="text" label="Parish Name" title="true" />
<perch:categories id="borough" set="boroughs" label="Borough" required="true" />
<perch:content id="location" type="map" label="Location" />
<perch:content id="church_size" type="text" label="Church Size" />
<perch:content id="status" type="select" label="Status" options="Active|active,Archived|archived" default="Active" />

If I save an item in my collection with these settings, I see the following errors:

Notice: Array to string conversion in /PATH TO/local/perch/core/apps/content/PerchContent_Util.class.php on line 70

Warning: Cannot modify header information - headers already sent by (output started at /PATH TO/local/perch/core/apps/content/PerchContent_Util.class.php:70) in /PATH TO/local/perch/core/lib/PerchUtil.class.php on line 1168

Warning: Cannot modify header information - headers already sent by (output started at /PATH TO/local/perch/core/apps/content/PerchContent_Util.class.php:70) in /PATH TO/local/perch/core/lib/PerchUtil.class.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /PATH TO/local/perch/core/apps/content/PerchContent_Util.class.php:70) in /PATH TO/local/perch/core/lib/PerchUtil.class.php on line 1170

Warning: Cannot modify header information - headers already sent by (output started at /PATH TO/local/perch/core/apps/content/PerchContent_Util.class.php:70) in /PATH TO/local/perch/core/lib/PerchUtil.class.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /PATH TO/local/perch/core/apps/content/PerchContent_Util.class.php:70) in /PATH TO/local/perch/core/inc/top.php on line 17

and my item gets named

St Giles-in-the-FieldsArray

(where the church is called "St Giles-in-the-Fields").

Ideally, it would pick up the title of the category, or the related item, but if not I guess it should ignore this, rather than try to name a region "Array".

Paul Bell

Paul Bell 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The only item you have title set for is parish_name.

Ah, Sorry - I think I must have tweaked the template to get rid of the error. The error I saw was as a result of adding title="true" to the Borough. I had a similar experience when I added it to a relationship field on a different template.

Sorry for the confusion.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What would be expected outcome be for and item with multiple categories?

Good question. I hadn't really thought of that. I guess under certain circumstances it might be useful to be able to have the title field of all the categories included.

Also, sometimes I'd find it helpful to be able to limit the number of categories or relationships to just one - in which case it would make more sense to be able to use this as the title. I wanted to make you aware of the error in any case, in case it was one you wanted to fix.

Drew McLellan

Drew McLellan 2638 points
Perch Support

The flexibility Perch offers brings with it all sorts of challenges. We try to balance them as best as possible.