7940 Posts in 1543 Topics by 946 members
|Go to End||Next >|
2 February 2011 at 9:46pm
it works. thx
But the is no way use tha files lke variables.
So my first question was is it possible have many files for each row?
Name --- Surname --- Description --- Attachment1 --- Attachment2
John Smith developer file1.zip file2.zip
I saw in all example this schema works only with a single file.
If i output with <% control Attchments %> i can't say that file2.zip is attachment2 and put it in a table td like a variable $Attachment
Thank you for your support.
4 February 2011 at 4:48am
Right.. well, tables are for flat data models. You're trying to flatten a model that is no longer flat. If your model had only one file attachment, you could use a table column for that field, but since you're now saying you have any number of file attachments, you can't have a uniform table anymore. The column count would be different on each row!
4 February 2011 at 4:56am
Thanks for your answer UncleCheese.
Do you know if there is something to manage flat data models so i need?
For each document of a section i need to manage many data with 3 attachment for each row..
I don't know how i can do it..
4 February 2011 at 5:45am
What you're describing doesn't make any sense. You're asking that each row of the table have a different number of columns.
Unless I'm misunderstanding you?
4 February 2011 at 6:02am
perhaps I have not explained well my issue.
I have a reserved area'ìè
1- Reserved area have childrens that are pages of members.
2 - Each page need to have dataobject to manage data of each members
well, dataoject need to have 5 columns:
Product Name, Description, Attachment1, Attachment2, Attachemnt3
Attachment1, Attachment2 and Attachment3 are files.
If i use only an Attachment all works ok. But if i need more than one file i don't know how do that.
I hope have explain good this time ;-)
sorry for my english..
4 February 2011 at 6:47am
So you only have 3 attachments per object? Never more than that?
4 February 2011 at 7:10am
Yes, but i need to manage the 3 attachments like variables.
For example my output must be:
In the past post you tell me to use <% control Attachments %> but in this way i can't control them one by one
I need to have an order to output files
every in the same position
4 February 2011 at 7:31am
So just do this:
class Resource extends DataObject
static $db = array (
'Name' => 'Text',
'Description' => 'Text',
'Category' => "Enum('Industry, Finance, Education')",
static $has_one = array (
'File1' => 'File',
'File2' => 'File',
'File3' => 'File',
'ResourcePage' => 'ResourcePage'
public function getCMSFields_forPopup()
return new FieldSet(
new DropdownField('Category','Category', singleton('Resource')->dbObject('Category')->enumValues()),
and this is the ResourcePage.php
class ResourcePage extends Page
static $has_many = array (
'Resources' => 'Resource'
public function getCMSFields()
$f = parent::getCMSFields();
$manager = new DataObjectManager(
$this, // Controller
'Resources', // Source name
'Resource', // Source class
'Name' => 'Name',
'Description' => 'Description',
'Category' => 'Category',
'File1.Name' => 'File1',
'File2.Name' => 'File2',
'File3.Name' => 'File3',
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
class ResourcePage_Controller extends Page_Controller
|Go to Top||Next >|