I'm using Sonata admin on Symfony 2.1.3. Now trying to add text input with google map.
Added line in configureFormFields() function:
->add('coordinates', 'contentbundle_coordinates_map', array('required' => false,'attr'=>array('class'=>'mapCoordinate')))
registred in services and created template for this:
{% block contentbundle_coordinates_map_widget %}
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="{{ asset('js/add.scripts.js') }}"></script>
<input type="text" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
<div id="add_map" class="map" style="width:500px;height:300px;"></div>
{% endblock %}
Can see my field with map in admin content add page, but when I want to submit data getting:
Notice: Array to string conversion in D:\my_vendor_folder\doctrine\dbal\lib\Doctrine\DBAL\Statement.php line 103
If I change contentbundle_coordinates_map with null:
->add('coordinates', null, array('required' => false,'attr'=>array('class'=>'mapCoordinate')))
everything works.
Where is the problem?
UPDATE
Form Type Class:
namespace Map\ContentBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class CoordinatesMapType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function getName()
{
return 'contentbundle_coordinates_map';
}
}
contentbundle_coordinates_map. My first guess would be that itsgetParent()method isn't returning the correct type. - RobMasters