Created
March 7, 2011 23:25
-
-
Save dantleech/859499 to your computer and use it in GitHub Desktop.
More ideas on the Ylly table bundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Ylly\YllyBackOfficeBundle\Table; | |
use Ylly\YllyTableBundle\Table\Table; | |
class SiteManageTable extends Table | |
{ | |
public function configure() | |
{ | |
// CURRENT API | |
$this->addColumn(new Column('check', 'check', null, new Cell('check'))); | |
$this->addColumn(new Column('primary_contact', null, 'NAME', new Cell('primary_contact'))); | |
$this->addColumn(new Column('email_telephone', null, 'EMAIL_TELEPHONE', new Cell('email_telephone'))); | |
$this->addColumn(new Column('host', null, 'HOST', new Cell('host'))); | |
$this->addColumn(new Column('created_at', null, 'CREATED_AT', new Cell('date'))); | |
$this->addColumn(new Column('actions', null, 'ACTIONS', new Cell('actions'))); | |
// POSSIBLE API .. | |
$this->createColumn() | |
->template('th_checkbox') | |
->cellPrototype($this->createCell('check')->setTemplate('checkbox')); | |
$this->createColumn() | |
->title('Primary Contact') | |
->valueFrom(function ($data) { return $data->getCompany()->getPrimaryContact(); }) | |
->cellPrototype($this->createCell()->template('primary_contact')); | |
$this->createColumn() | |
->title('Email / Telephone') | |
->cellPrototype($this->createCell()->template('email_telephone')); | |
$this->createColumn() | |
->title('Host') | |
->valueFrom(function ($data) { return $data->getHost(); }) | |
->cellPrototype($this->createCell()->template('host')); | |
$this->createColumn() | |
->title('Created At') | |
->valueFrom(function ($data) { return $data->getCreatedAt(); }) | |
->cellPrototype($this->createCell()->template('date')); | |
$this->createColumn() | |
->title('Actions') | |
->cellPrototype($this->createCell()->template('actions')); | |
} | |
} | |
?> | |
// Table in template. Overload or extend template specified | |
// this works now. | |
{% table siteManagerTable with "MyBundle:Foo:table.html.twig" %} | |
{% block checkbox %} | |
<td><input type="checkbox" name="row[{{ cell.getData().getId() }}]"/></td> | |
{% endblock %} | |
{% block primary_contact %} | |
<td><span style="color: green">{{ cell.getValue() }}</span></td> | |
{% endblock %} | |
{% block email_telephone %} | |
<td> | |
<ul> | |
<li>{{ cell.getData().getEmail() }}</li> | |
<li>{{ cell.getData().getTelephone() }}</li> | |
</ul> | |
</td> | |
{% endblock %} | |
{% block host %} | |
<td> | |
<a href="{{ path('site_view', {'site_id': data.getId()} }}">{{ cell.getData().getHost() }} <!-- OR !--> {{ cell.getValue() }}</a> | |
</td> | |
{% endblock %} | |
{% block date %} | |
<td> | |
{{ cell.getValue().format('d-m-Y') }} | |
</td> | |
{% endblock %} | |
{% block actions %} | |
<td> | |
<ul> | |
<li>Action 1</li> | |
<li>Action 2</li> | |
</ul> | |
</td> | |
{% endblock %} | |
{% endtable %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment