Last active
October 7, 2015 15:47
-
-
Save tristanbes/3188331 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
<?php | |
namespace AwesomeNamespace\AwesomeBundle\Admin; | |
use Sonata\AdminBundle\Admin\Admin; | |
use Sonata\AdminBundle\Form\FormMapper; | |
use Sonata\AdminBundle\Datagrid\ListMapper; | |
/** | |
* Profile Admin | |
*/ | |
class ProfileAdmin extends Admin | |
{ | |
/** | |
* Configure the list | |
* | |
* @param \Sonata\AdminBundle\Datagrid\ListMapper $list list | |
*/ | |
protected function configureListFields(ListMapper $list) | |
{ | |
$list | |
->addIdentifier('name', null, array('label' => 'Name')) | |
->add('description', null, array('label' => 'Description')); | |
} | |
/** | |
* Configure the form | |
* | |
* @param FormMapper $formMapper formMapper | |
*/ | |
public function configureFormFields(FormMapper $formMapper) | |
{ | |
$formMapper | |
->add('translations', 'a2lix_translations', array( | |
'by_reference' => false, | |
'locales' => array('fr', 'en')) | |
); | |
} | |
} |
Hello,
The solution to this error is put nullable=true in name and description.
Hello,
@tristanbes Now I have a problem, AdminSonata want __toString() function, but how I can create this function to print one field in one language?
Another problem, is that listview don't print anything, I would like print every filed but in one language only. Is possible?
Thanks
Regards
@mrcmorales Sorry it seems that github didn't send me notif so i didn't see your comments.
For the __toString, don't worry about it, just put :
public function __toString()
{
return (string) $this->getName();
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @tristanbes ,
I have this error when I create a new Profile.
I have the same code that in your blog example.
An exception occurred while executing 'INSERT INTO profile (name, description) VALUES (?, ?)' with params {"1":null,"2":null}:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null
Thanks
Regards