Forums / Setup & design / Problem with edit integer field

Problem with edit integer field

Author Message

Lida Popelo

Monday 20 September 2004 9:35:45 am

Hello!
I have a class with a field of type Integer, in this field i'm going to store section id. So i want that this field apear as ComboBox with avaible sections, not a TextBox (as default for Integer type).

I override template "content/datatype/edit/ezinteger.tpl" and put in it following code:

{let section_list = fetch(content, section_list)}

<select name="???????" size="1">

{section var = section loop = $section_list}
  <option value = {$section.id}>{$section.name}</option>
{/section}

</select>

{/let}

It works ok, but what a value i need to assign to 'name' attribute ?

Frederik Holljen

Tuesday 21 September 2004 12:14:40 am

Try:

{default attribute_base=ContentObjectAttribute}
 <select name="{$attribute_base}_data_integer_{$attribute.id}" size="1">
  // your options here.
 </select>
{/default}

This is the way the default template sets the name. I'm not entirely sure it will work in your case, but it is worth a try.

Lida Popelo

Tuesday 21 September 2004 8:20:18 am

Tnank You very much!!!!

It works right for me...
But i think, i doesn't completely understand what the string below means :(

{$attribute_base}_data_integer_{$attribute.id}

Can anybody give me explanation (or link where i can find one) about code in design/standard/templates/content/edit_attribute.tpl,
design/standard/templates/content/datatype/edit/*.tpl

Best Regards,
Lida

Frederik Holljen

Tuesday 21 September 2004 9:27:44 am

This is the way eZ publish recognizes data input. The name of the input field will be something like:
ContentObjectAttribute_data_integer_11. This specific string is recoginized by eZ publish which compares it with the actuall specification of your class. If the name of the input field matches the class definition the data is stored.