eZ Community » Forums » General » form fields, default value
expandshrink

form fields, default value

form fields, default value

Monday 14 December 2009 1:32:12 pm - 4 replies

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

Monday 14 December 2009 2:50:49 pm

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,

Monday 14 December 2009 7:06:41 pm

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

Monday 14 December 2009 7:26:11 pm

Glad to hear it worked.

Cheers!

Monday 14 December 2009 7:43:49 pm

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 blunk.gif Emoticon

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from