Search

Yesterday I had trouble because I output a variable from my datasource that had an underscore in it which was transformed into a hyphen when it was placed in the list of available page parameters. Today I struggled to get postbacks working in my Members registration form because the post back data was coming in with all of the field names' underscores replaced with hyphens.

Is there some documentation I missed that I am supposed to use hyphens for everything? To see this problem in two areas in two days is very discouraging - I know underscores in field names is not an uncommon naming convention. Perhaps there should be validation on the handle field so people don't use underscores when they have so much trouble? I know it won't let you use a space in a handle name, so the validation logic is present...

Do I need to go into all of my sections and change all of my field names, or is this underscore replacing just a case of a couple of unlikely bugs I was unlucky enough to encounter one after another and I should just file issues?

Thanks for reading.

Generally speaking, Symphony works with handles everywhere: Section handles, Field handles, XML node names etc. General::createHandle() is king.

I know underscores in field names is not an uncommon naming convention.

Perhaps you are referring to database table field names? Indeed, it's a very good thing to use underscore there. But Symphony's Fields are higher level entities and the best and enforced way to use them is with handlised names.

Hi Sarah,

I know underscores in field names is not an uncommon naming convention.

I can agree here, when we're talking about fields in databases, but as Symphony is a kind of pseudo database, we tend to use hyphens as the values can be used in urls. It also creates a standard approach throughout the xml, xslt, url handles and any output field names in html.

To see this problem in two areas in two days is very discouraging

I wouldn't like to think you're discouraged from using Symphony, it seems you're really getting a handle on how this stuff works very quickly, and that's to be admired as we admittedly have an issue with documentation.

It is a standard approach for our system to use hyphens throughout as I've said above. If the issue is external XML using underscores, then that shouldn't be a problem, as long as when it is used internally in Symphony, hyphens are used.

Do I need to go into all of my sections and change all of my field names, or is this underscore replacing just a case of a couple of unlikely bugs I was unlucky enough to encounter one after another and I should just file issues?

Unfortunately yes. At least go through and check that the handles for each field use hyphens and don't have underscores in them. I think as a team we should look into throwing a validation error if the handles end up having underscores, which is why I asked for the ticket to be raised.

I hope this alleviates your issues a little and isn't too much of a bummer. If you want to know any more, don't hesitate to ask, we're all here for that.

Vlad beat me to it.

Alright. Thank you both for your quick responses. I will change my field handles and won't be making this mistake again! I hope validating against underscores is an eventual possibility, so some other dummy doesn't come along after me and bang their head against this same wall...

Maybe something could be added to this page talking about handles and warning people off of underscores?

I appreciate both the flattery and the explanation of the distinction between field handles and field names. You guys are really pushing the supportive community envelope here :P

At the end of the day, I guess Symphony doesn't really think about this because we don't expect users to think about hyphens or underscores. You just name your fields naturally so they are readable and magic happens :D

I would like to review your particular issue again though. If you're using field names with underscores, I'm not sure why the parameter suggestions would throw up the same field but using an underscore format. I'm also not sure why that wouldn't resolve to anything. Don't worry, I'm hoping to look deeper into the issue tomorrow to find out exactly where the breakdown occurs :)

I appreciate you taking the time to look at it (and making sure magic happens as much as it does!). Please let me know if I can help.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details