attribute_view_gui default value

Author Message

Michael Scofield

Monday 16 June 2008 8:11:33 pm

Hi!

Is there a way to inform the default value for an attribute when using attribute_view_gui() function?

I'm using this function to show a class attribute:

{attribute_view_gui attribute=$node.data_map.email}

And would like to to fill the default value for this attribute (e.g. HTML VALUE attribute for INPUT element).

I tried something like this:

{attribute_view_gui attribute=$node.data_map.email value='myemail@server.com'}

But it didn't work.

Any ideas?

Thank you
Michael

Michael Scofield

Tuesday 17 June 2008 12:49:12 am

Problem solved!

If anyone goes into this problem one day, I solved the problem doing template overrides for all datatype templates included in my formulary. That are:

content/datatype/collect/ezstring.tpl
content/datatype/collect/ezemail.tpl
content/datatype/collect/ezselection.tpl
content/datatype/collect/ezboolean.tpl

Inside this files I created some code to get the default value for each attribute from POST variables.

Thank you anyway.
Michael Scofield

Horst Lindlbauer

Thursday 17 July 2008 8:03:57 am

Hi Michael,
I wonder how your solution could possibly work, if you have more than one occurrence of a data type?
I think a better solution is to have a look at the collect templates which attribute_view_gui uses in forms and learn from the html there.

If

{attribute_view_gui attribute=$node.object.data_map.your_attribute size='30'}

produces the correct input field for an attribute, the following code works to implement a default value :

<input class="box" type="text" size="30" name="ContentObjectAttribute_ezstring_data_text_{$node.object.data_map.your_attribute.id}"  	value="{$my_default_value}" />

Thereby it is also possible to pass the default value to a hidden field off course:

<input type="hidden" name="ContentObjectAttribute_ezstring_data_text_{$node.object.data_map.your_attribute.id}"  	value="{$my_default_value}" />

This worked perfectly for me and it should be easy to transfer this solution to other datatypes.

---------------------------------------
http://www.lbm-services.de

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 31 2025 00:36:31
Script start
Timing: Jan 31 2025 00:36:31
Module start 'layout'
Timing: Jan 31 2025 00:36:31
Module start 'content'
Timing: Jan 31 2025 00:36:31
Module end 'content'
Timing: Jan 31 2025 00:36:31
Script end

Main resources:

Total runtime0.0229 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0046 588.1406151.2109
Module start 'layout' 0.00460.0040 739.3516220.6875
Module start 'content' 0.00860.0131 960.0391997.8203
Module end 'content' 0.02170.0012 1,957.859433.9922
Script end 0.0229  1,991.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002310.0826140.0002
Check MTime0.00104.3198140.0001
Mysql Total
Database connection0.00083.295010.0008
Mysqli_queries0.002711.843030.0009
Looping result0.00000.047910.0000
Template Total0.00093.810.0009
Template load0.00073.081710.0007
Template processing0.00020.728310.0002
Override
Cache load0.00041.959110.0004
General
dbfile0.00167.057180.0002
String conversion0.00000.031240.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