form fields, default value

Author Message

Don Blogger

Monday 14 December 2009 4:32:12 am

Hi,

I'm creating a form using a content class as the information collector, outputting form fields, e. g., like {attribute_view_gui attribute=$node.data_map.firstname} - this works correctly, but I would like to pre-set a default value (the html input value attribute).

Any ideas how I could do that?

the result should be the input tag like <input type="text" name="dfssdafs" value="predefined value" />

Thanks in advance,

DB

Nicolas Pastorino

Monday 14 December 2009 5:50:49 am

Hi Don,

You may want to create an override for the information collection template for the concerned attributes. By default, the template used when displaying information collection attributes are :

 design/standard/templates/content/datatype/collect/<data_type_string>.tpl

where <data_type_string> is the type of attribute used. For a Text Line attribute it is 'ezstring'. Creating an override for these templates goes like this :

  1. copy the aforementioned template in you design. If your design is called 'my_design', the path will be :
     extension/my_extension/design/my_design/templates/content/datatype/collect/ezstring.tpl
  2. Then modify the override so that it displays a default value when applicable

We can imagine these default values be stored in an INI file for instance, from which you'd get the default values by using the 'ezini' operator.

Let us know how it goes,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Don Blogger

Monday 14 December 2009 10:06:41 am

Hi Nicolas,

Thanks a lot, mate! I did en override of ezstring and then modified the original template's copy so that it took a parameter "defaultValue" which was introduced in the input tag when the form field's content isn't set.

Since the default values are of the type "firstname, lastname, ..." I opted for taking the content class default value instead of the ezini-solution - will consider this solution for other projects, though.

Thank you very much!

DB

Nicolas Pastorino

Monday 14 December 2009 10:26:11 am

Glad to hear it worked.

Cheers!

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Don Blogger

Monday 14 December 2009 10:43:49 am

forgot to mention, of course, that there are no default values for certain data types, so a "quick and dirty" <input type="text" name="email" [...] defaultValue='E-Mail' /> did the trick ;-)

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 00:57:14
Script start
Timing: Jan 30 2025 00:57:14
Module start 'layout'
Timing: Jan 30 2025 00:57:14
Module start 'content'
Timing: Jan 30 2025 00:57:14
Module end 'content'
Timing: Jan 30 2025 00:57:14
Script end

Main resources:

Total runtime0.0144 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.1250151.2109
Module start 'layout' 0.00500.0023 739.335936.6484
Module start 'content' 0.00730.0055 775.984494.7344
Module end 'content' 0.01280.0016 870.718837.9922
Script end 0.0144  908.7109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002416.5887140.0002
Check MTime0.00117.3527140.0001
Mysql Total
Database connection0.00075.173510.0007
Mysqli_queries0.002013.979630.0007
Looping result0.00000.069410.0000
Template Total0.00128.110.0012
Template load0.00096.053110.0009
Template processing0.00032.032010.0003
Override
Cache load0.00064.217910.0006
General
dbfile0.001812.185680.0002
String conversion0.00000.039740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs