-
-
Save Heyfara/5c27ad69f805cd75fac1 to your computer and use it in GitHub Desktop.
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
// Route to this action : route_department_list | |
public function listDepartmentAction(Request $request) | |
{ | |
$form = $this->createFormBuilder() | |
->add('name', 'text') | |
->add('sigle', 'text') | |
->add('responsable', 'text') | |
->getForm(); | |
if ($request->isMethod('POST')) { | |
$form->bind($request); | |
$data = $form->getData(); | |
$contentClassIdentifier = 'service'; | |
$parentId = '2'; | |
$repository = $this->getRepository(); | |
$contentService = $repository->getContentService(); | |
$contentTypeService = $repository->getContentTypeService(); | |
$locationService = $repository->getLocationService(); | |
$contentType = $contentTypeService->loadContentTypeByIdentifier( $contentClassIdentifier ); | |
$locationCreateStruct = $locationService->newLocationCreateStruct( $parentId ); | |
$contentCreateStruct = $contentService->newContentCreateStruct( $contentType, 'fre-FR' ); | |
$contentCreateStruct->setField( 'name', $data['name'] ); | |
$contentCreateStruct->setField( 'sigle', $data['sigle'] ); | |
$contentCreateStruct->setField( 'responsable', $data['responsable'] ); | |
$draft = $contentService->createContent( $contentCreateStruct, array( $locationCreateStruct ) ); | |
$content = $contentService->publishVersion( $draft->versionInfo ); | |
// Redirect to the object list | |
return $this->redirect($this->generateUrl('route_department_list')); | |
} | |
// Display the list of existing objects and the form to create a new one | |
return $this->render('MyBundle:Config:departmentList.html.twig', array('form' => $form->createView())); | |
} |
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
{% extends 'MyBundle:Default:index.html.twig' %} | |
{% block title %} | |
Paramétrage des services | |
{% endblock %} | |
{% block menuBar %} | |
{% include 'MyBundle:Dashboard:menuBar.html.twig' %} | |
{% endblock %} | |
{% block content %} | |
<div class="container"> | |
<div class="hero-unit"> | |
<h1>Paramétrage</h1> | |
<p>Paramétrage des services</p> | |
{% include 'MyBundle:Dashboard:searchForm.html.twig' %} | |
</div> | |
<div class="container-fluid"> | |
<div class="row-fluid"> | |
<div class="span12"> | |
<!--Body content--> | |
<table> | |
<tr> | |
<th>Nom</th> | |
<th>Sigle</th> | |
<th>Responsable</th> | |
</tr> | |
{% include 'MyBundle:Config:department.html.twig' %} | |
</table> | |
<hr> | |
<h3>Ajouter un nouveau service</h3> | |
<form action="{{ url('route_department_list') }}" method="post" {{ form_enctype(form) }}> | |
{{ form_widget(form) }} | |
<input type="submit" /> | |
</form> | |
</div> | |
</div> | |
</div> | |
</div> <!-- /container --> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment