mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Removed some line breaks for code blocks to render properly in the doc module
See <http://doc.silverstripe.org/framework/en/tutorials/5-dataobject-relationship-management> for what I mean
This commit is contained in:
parent
2939632778
commit
1434190c36
@ -127,16 +127,13 @@ All customization to fields for a page type are managed through a method called
|
|||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
// Get the fields from the parent implementation
|
// Get the fields from the parent implementation
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
// Create a default configuration for the new GridField, allowing record editing
|
// Create a default configuration for the new GridField, allowing record editing
|
||||||
$config = GridFieldConfig_RelationEditor::create();
|
$config = GridFieldConfig_RelationEditor::create();
|
||||||
|
|
||||||
// Set the names and data for our gridfield columns
|
// Set the names and data for our gridfield columns
|
||||||
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
|
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
|
||||||
'Name' => 'Name',
|
'Name' => 'Name',
|
||||||
'Project.Title'=> 'Project' // Retrieve from a has-one relationship
|
'Project.Title'=> 'Project' // Retrieve from a has-one relationship
|
||||||
));
|
));
|
||||||
|
|
||||||
// Create a gridfield to hold the student relationship
|
// Create a gridfield to hold the student relationship
|
||||||
$studentsField = new GridField(
|
$studentsField = new GridField(
|
||||||
'Students', // Field name
|
'Students', // Field name
|
||||||
@ -144,10 +141,8 @@ All customization to fields for a page type are managed through a method called
|
|||||||
$this->Students(), // List of all related students
|
$this->Students(), // List of all related students
|
||||||
$config
|
$config
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create a tab named "Students" and add our field to it
|
// Create a tab named "Students" and add our field to it
|
||||||
$fields->addFieldToTab('Root.Students', $studentsField);
|
$fields->addFieldToTab('Root.Students', $studentsField);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,7 +227,6 @@ to configure it a bit differently.
|
|||||||
// ...
|
// ...
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// Same setup, but for mentors
|
// Same setup, but for mentors
|
||||||
$mentorsField = new GridField(
|
$mentorsField = new GridField(
|
||||||
'Mentors',
|
'Mentors',
|
||||||
@ -241,7 +235,6 @@ to configure it a bit differently.
|
|||||||
GridFieldConfig_RelationEditor::create()
|
GridFieldConfig_RelationEditor::create()
|
||||||
);
|
);
|
||||||
$fields->addFieldToTab('Root.Mentors', $mentorsField);
|
$fields->addFieldToTab('Root.Mentors', $mentorsField);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,7 +283,6 @@ a named list of object.
|
|||||||
<h1>$Title</h1>
|
<h1>$Title</h1>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
$Content
|
$Content
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -349,7 +341,6 @@ we can access the "Students" and "Mentors" relationships directly in the templat
|
|||||||
<h1>$Title</h1>
|
<h1>$Title</h1>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
$Content
|
$Content
|
||||||
|
|
||||||
<h2>Students</h2>
|
<h2>Students</h2>
|
||||||
<% if Students %>
|
<% if Students %>
|
||||||
<ul>
|
<ul>
|
||||||
@ -360,7 +351,6 @@ we can access the "Students" and "Mentors" relationships directly in the templat
|
|||||||
<% else %>
|
<% else %>
|
||||||
<p>No students found</p>
|
<p>No students found</p>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<h2>Mentors</h2>
|
<h2>Mentors</h2>
|
||||||
<% if Mentors %>
|
<% if Mentors %>
|
||||||
<ul>
|
<ul>
|
||||||
@ -371,7 +361,6 @@ we can access the "Students" and "Mentors" relationships directly in the templat
|
|||||||
<% else %>
|
<% else %>
|
||||||
<p>No mentors found</p>
|
<p>No mentors found</p>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user