CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Smarty Variable - Hyphen in Array Key
Pages: [1]

Author Topic: Smarty Variable - Hyphen in Array Key  (Read 1905 times)

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Smarty Variable - Hyphen in Array Key
February 16, 2012, 09:25:17 pm
Trying to create a custom template for a profile, but CiviCRM stores several fields as Smarty variables with a hypen in the array key, which I can't figure out how to use.

For example, phone numbers may be stored as
Code: [Select]
phone-1-1 => Array (9)
  name => "phone-1-1"
  value => "(555) 555-5555"
  type => "text"
  frozen => false
  required => false
  error => null
  id => "phone-1-1"
  label => "<label for="phone-1-1">Phone Number (..."
  html => "<input maxlength="32" size="20" name=..."

So trying to print the smarty variable using:
Code: [Select]
{$form.phone-1-1.label}
fails because of the hyphens.

Firstly, is there a way to print variables with hyphens in them?

Secondly, should we be name fields in this way?

Thanks,

Brian

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Smarty Variable - Hyphen in Array Key
February 17, 2012, 06:35:23 am

u'll need to do something like

Code: [Select]
{assign var=varName value='phone-1-1'}
{$form.$varName.html}

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: Smarty Variable - Hyphen in Array Key
February 17, 2012, 08:52:06 am
Thanks - that does it.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Smarty Variable - Hyphen in Array Key

This forum was archived on 2017-11-26.