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 CiviEvent (Moderator: Yashodha Chaku) »
  • Different field lengths for custom fields?
Pages: [1]

Author Topic: Different field lengths for custom fields?  (Read 1201 times)

Semp2pts

  • Guest
Different field lengths for custom fields?
May 20, 2009, 05:12:43 am
I can't for the life of me figure this one out. I want, for example, the email input field to be much wider than the postcode field. All custom inputs are the same length. Is there a way to set the length of each field?

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: Different field lengths for custom fields?
May 20, 2009, 07:06:36 am

Not in the current version of CiviCRM. You will need to use a custom template to do have different fields have a different text length

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

ThePayIsLousy

  • Guest
Re: Different field lengths for custom fields?
August 29, 2009, 07:09:46 pm
lobo,

I'd like to do this, too.  Could you point me towards an example of how to modify the display length of a field?  I have created a custom template (view.tpl), so I'm familiar w/ that part of the process.  You know I'll document it if you get me started!  :)  Thanks!

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: Different field lengths for custom fields?
August 29, 2009, 08:08:52 pm

the easiest way to do this is to use a custom template:

For all form elements that you want with a different size, use crmReplace. sample code is below

Code: [Select]
{$form.mailing_format.html|crmReplace:class:huge}

the list of classes can be found in css/civicrm.css
Code: [Select]
#crm-container .two {width: 2em;}
#crm-container .four {width: 4em;}
#crm-container .six {width: 6em;}
#crm-container .eight {width: 8em;}
#crm-container .twelve {width: 12em;}
#crm-container .twenty {width: 20em;}
#crm-container .medium {width: 12em;}
#crm-container .big {width: 15em;}
#crm-container .huge {width: 25em;}

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

ThePayIsLousy

  • Guest
Re: Different field lengths for custom fields?
August 30, 2009, 07:47:21 am
Thanks, lobo.  Can you point me to a complete example of a similar replacement?  I think I understand the snippet you posted, but I don't know what to do w/ it.  Specifically:

--To affect a profile edit form, do I want a copy of Dynamic.tpl?  edit.tpl appears to just include Dynamic.

--In 
Code: [Select]
{$form.mailing_format.html|crmReplace:class:huge} , mailing_format is the name of the field?  Where do I get the name for my fields?  Viewing the page source of the edit form displays, e.g., custom_68.  The database name might be last_modified_47.

--Do I need logic to differentiate between profiles, or are the field names (mailing_format, custom_68, whatever it s/be) guaranteed to be unique across all profiles?  [I.e., if I have a mailing_format (or custom_68) field on two profile forms, will I need a /2/ and a /3/ .tpl file for profile forms #2 and #3?]

--Where should I insert
Code: [Select]
{$form.mailing_format.html|crmReplace:class:huge} into the .tpl code?


Once I have this working, should I link to a wiki page from here (on the 3.0 tree), or is there a more logical place?
http://wiki.civicrm.org/confluence/display/CRMDOC/Customize+Built-in%2C+Profile%2C+Contribution+and+Event+Registration+Screens

Thanks!

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: Different field lengths for custom fields?
August 30, 2009, 05:15:31 pm

hey mike:

dont have a complete example handy, but we use this in quite a few places in the core code :)

to answer your questions:

1. due to a bug, u need to actually customize edit.tpl. I just copy dynamic.tpl to edit.tpl and make the changes there

2. you can get the name of the field by either checking the smarty template or in the case of custom fields doing a smarty debug. custom fields are always called, custom_ABCD within the code / templates

3. the field names should be consistent across all profiles. However depending on how u've set things, some profiles will not have that field included

4. I would make it a subpage in the 3.0 doc tree (CRMUPCOMING) as a child of the Customize Built .... page

ping me on irc if u have more questions etc / want more detailed reply :0

lobo

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Different field lengths for custom fields?

This forum was archived on 2017-11-26.