protected function configureFormFields(FormMapper $formMapper)
{
$em = $this->modelManager->getEntityManager('MyBundle\Entity\Categoria');
$query = $em->createQuery('SELECT b FROM MyBundle:Categoria b WHERE b.name = :name');
$query->setParameter('name', 'name_of_categoria');
$formMapper
$user = $this->getConfigurationPool()->getContainer()->get('security.token_storage')->getToken()->getUser();
Follow this guide: http://symfony.com/doc/current/controller/upload_file.html There is no problem using the same file field, that I use for the sonata admin guide. This allows in theory separate all the upload code from the entity code, but it didn't work in sonata admin, so I'll have to look for a complement to this.
First configure ACL permissions correctly:
https://sonata-project.org/bundles/admin/master/doc/reference/security.html
Remember these 3 things explained in the link:
*Install the ACL tables: php app/console init:acl
Look in composer for:
"config": {
"preferred-install": "dist",
"platform": {
"php": "5.3.9"
}
}
package in.wptrafficanalyzer.additemsdynamically;
import java.util.ArrayList;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
If is just a parameter use:
$page = $request->query->get('page');
If you have to get a form value do this (pais is a field of the form):
$data = $formtest->getData();
In the layout:
<EditText
android:id="@+id/textArea_information"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:gravity="top|left"
Source: http://antonioleiva.com/recyclerview-listener/
If you’ve used a RecyclerView, you may know that they don’t have a setOnItemClickListener as ListView had, so we have to create our own way to do it. Many people asked me how to do this, so that’s why I decided to write about it. There are many ways to achieve this, but I will show you the way I usually do it. My mechanism consists of passing the listener as a parameter to the constructor and then assign it when I bind the data to the view in onBindViewHolder. You’ll first need an interface that specifies listener’s behaviour. In this example, there is a sample model called ContentItem, so the click will return an item of that type:
public interface OnItemClickListener {
void onItemClick(ContentItem item);
}
In the layout:
<CheckBox android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="new checkbox"
android:background="@drawable/checkbox_background"
android:button="@drawable/checkbox" />
Where @drawable/checkbox is: