templates for fields

A place for users and developers of the Xataface to discuss and receive support.

templates for fields

Postby shardison » Mon Nov 12, 2012 2:47 pm

Is there a way to create a template for a field that would automatically supply dashes or slashes when someone is editing or entering data.

For example for dates
/ /
or for social security numbers
- -
so that as someone enters a date they only have to enter numbers and they would show up in the right place automatically. Or as someone enters a social security number the dashes will be supplied automatically

Thanks
Seth
shardison
 
Posts: 24
Joined: Wed Aug 08, 2012 12:09 pm

Re: templates for fields

Postby Jean » Tue Nov 13, 2012 2:11 am

Why don't you use 3 fields with a javascript to put the cursor in the right field ? Then you join them with a beforeSave trigger in a calculated field.
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: templates for fields

Postby shannah » Tue Nov 13, 2012 9:06 am

You could either do this with javascript by attaching a change handler to the field; or you could do this with a beforeSave() trigger in PHP to modify it before it is saved. The way I usually do it is to remove all formatting for the saved version (if I care about format at all), using the beforeSave() trigger, then I format it the way I want with the fieldname__display() delegate method.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: templates for fields

Postby shardison » Sat Nov 24, 2012 11:55 am

Steve,
I agree that I can run a javascript to handle the input mask. I was wondering if jquery is loaded by default with xataface or do I have to explicitly call it and the javascript I have for the input mask that relies on jquery?
shardison
 
Posts: 24
Joined: Wed Aug 08, 2012 12:09 pm

Re: templates for fields

Postby shardison » Sun Nov 25, 2012 7:58 am

I found that jquery does load by default. I found a cool javascript called maskedinput.js at http://digitalbush.com/projects/masked-input-plugin/ that has the ability to create many types of input mask. The script was created by Josh Bush. I don't want to take any credit for the solution. The internet is an awesome bedrock for collaborative work. Just want to give a shout out to all the people like Steve who advance software development
shardison
 
Posts: 24
Joined: Wed Aug 08, 2012 12:09 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved