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.