Forums / Developer / attribute_view_gui default value

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

eZ debug

Timing: Jan 20 2025 14:24:54
Script start
Timing: Jan 20 2025 14:24:54
Module start 'content'
Timing: Jan 20 2025 14:24:54
Module end 'content'
Timing: Jan 20 2025 14:24:54
Script end

Main resources:

Total runtime0.1152 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 590.5781180.8281
Module start 'content' 0.00550.0053 771.406393.8984
Module end 'content' 0.01080.1043 865.3047522.5469
Script end 0.1151  1,387.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00302.5739200.0001
Check MTime0.00121.0496200.0001
Mysql Total
Database connection0.00060.492410.0006
Mysqli_queries0.078468.03391410.0006
Looping result0.00100.82481390.0000
Template Total0.104190.310.1041
Template load0.00060.526910.0006
Template processing0.103589.815410.1035
Override
Cache load0.00040.371510.0004
Sytem overhead
Fetch class attribute can translate value0.00060.528810.0006
XML
Image XML parsing0.00020.207410.0002
General
dbfile0.00393.3438200.0002
String conversion0.00000.005430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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