5101 Posts in 1519 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1417 Views |
-
ComplexTableField for all entries

6 April 2010 at 4:02am
I try to use the ComplexTableField in a LeftAndMain to allow the user to edit all entries of one type (dataobject)
VIPAdmin.php
<?
class VIPAdmin extends LeftAndMain {
static $url_segment = "vip";
static $url_rule = '$Action';
static $menu_title = "VIP Editor";
static $menu_property = 60;function getEditor() {
$editor = new ComplexTableField(
$this,
'VIPs',
'VIP',
array('Name','Spruch'),
new FieldSet(
new TextField('Name'),
new TextareaField('Spruch')
)
);
$editor->setParentClass(false);
return new FieldSet($editor);
}
function VIPs() {
return DataObject::get('VIP');
}
}?>
VIP.php
<?
class VIP extends DataObject {
static $db = array(
"Name" => "Varchar(50)",
"Spruch" => "Text"
);
static $has_one = array(
"Bild" => "Image"
);
}?>
VIPAdmin_right.ss
<h1>VIP Editor</h1>
<% if Editor %>
$Editor
<% else %>
Kein Editor
<% end_if %>if i replace the "return new FieldSet($editor);" with a "return "Hello World!"; " it works. however with the $editor. it shows blank unless the h1-tag
Thx for your help.
ps.: sry for my broken english. im from germany
-
Re: ComplexTableField for all entries

6 April 2010 at 9:58am
when just returning the complextablefield i get a (none).
hope this is helpful -
Re: ComplexTableField for all entries

6 April 2010 at 10:51pm Last edited: 6 April 2010 11:29pm
Got it with this example: http://doc.silverstripe.org/doku.php?id=leftandmain#subclassing
i needed to use a Form.
Now i got the "i can't sub-URLs of xyz"-Error with my VIPAdmin Thingy
VIPAdmin.php
<?
class VIPAdmin extends LeftAndMain {
static $url_segment = "vip";
static $url_rule = '$Action';
static $menu_title = "VIP Editor";
static $menu_property = 60;function init() {
parent::init();
//Requirements::css("sapphire/css/ComplexTableField.css");
}function Editor() {
$editor = new ComplexTableField(
$this,
'Editor',
'VIP',
array('Name','Spruch'),
'getCMSFields'
);
//$editor->setReadOnly(false);
$editor->setCustomSourceItems( DataObject::get('VIP') );
/*$editor->setPermissions(array(
'delete',
'export',
'print',
'edit'
));*/
//return $editor;
return new Form($this,"EditForm",
new FieldSet(
new HiddenField('ID', ''),
$editor
),
new FieldSet(new FormAction('go'))
);
}
function VIPs() {
return new DataObjectSet();
}
}?>
Url i try to access: http://***/***/admin/vip/EditForm/field/Editor/add
Error i get: I can't handle sub-URLs of a VIPAdmin object. -
Re: ComplexTableField for all entries

24 September 2010 at 9:55pm
I have a similar problem and I'm still looking for a solution (see http://ssorg.bigbird.silverstripe.com/customising-the-cms/show/292590). How did you solve this?
| 1417 Views | ||
|
Page:
1
|
Go to Top |

