php - The "replace" filter expects an array or "Traversable" as replace values, got "string" -


i'm using php 5.6 develop app want upgrade php 7.0. fact is, when build form app give me error: "replace" filter expects array or "traversable" replace values, got "string".

error

this code i'm using build form:

<?php  namespace pozo\metrajebundle\form;  use symfony\component\form\abstracttype; use symfony\component\form\formbuilderinterface; use symfony\component\optionsresolver\optionsresolver;  class metrajediariotype extends abstracttype {     /**      * @param formbuilderinterface $builder      * @param array $options      */     public function buildform(formbuilderinterface $builder, array $options)     {         $builder             ->add('metrosperforados', null, array('label'=>'commons.drillmt'))             ->add('sidetrack', null, array('label'=>'commons.sidetrack'))             ->add('descripcion', null, array(                 'label' => 'commons.description',                 'label_attr' => array("class" => "hide"),                 "attr" => array("class" => "hide")             ))         ;     }      /**      * @param optionsresolver $resolver      */     public function configureoptions(optionsresolver $resolver)     {         $resolver->setdefaults(array(             'data_class' => 'pozo\metrajebundle\entity\metrajediario',             'translation_domain' => 'labels'         ));     }      /**      * @return string      */     public function getname()     {         return 'pozo_metrajebundle_metrajediario';     } } 

i error when line {{ form_rest(form) }} executed.

this entity.

<?php  namespace pozo\metrajebundle\entity;  use doctrine\orm\mapping orm; use symfony\component\validator\constraints assert; use symfony\component\validator\context\executioncontext;  /**  * metrajediario  *  * @orm\table()  * @orm\entity(repositoryclass="pozo\metrajebundle\entity\metrajediariorepository")  * @assert\callback(methods={"validarmetraje"})  */ class metrajediario {     /**      * @var integer      *      * @orm\column(name="id", type="integer")      * @orm\id      * @orm\generatedvalue(strategy="auto")      */     private $id;      /**      * @var \datetime      *      * @orm\column(name="fecha", type="date")      */     private $fecha;      /**      * @var float      *      * @orm\column(name="metrosperforados", type="float")      */     private $metrosperforados;      /**      * @var float      *      * @orm\column(name="profundidadinicial", type="float")      */     private $profundidadinicial;      /**      * @orm\manytoone(targetentity="dipp\pozobundle\entity\pozo")      * @orm\joincolumn(name="pozo_id", referencedcolumnname="id", nullable=false)      */     private $pozo;      /**      * @var string      *      * @orm\column(name="descripcion", type="text", nullable=true)      */     private $descripcion;      /**      * @var boolean      *      * @orm\column(name="sidetrack", type="boolean", nullable=true)      */     private $sidetrack;      /**      * @param executioncontext $context      * @return void      */     public function validarmetraje(executioncontext $context)     {         if($this->sidetrack)         {             if ( $this->metrosperforados >= $this->profundidadinicial )             {                 $context->addviolationat('metrosperforados','un sidetrack debe ser menor que la profundidad inicial.');             }         }         else         {             if ( $this->metrosperforados < $this->profundidadinicial )             {                 $context->addviolationat('metrosperforados','el metraje debe ser mayor o igual que la profundidad inicial.');             }         }     }      /**      * id      *      * @return integer       */     public function getid()     {         return $this->id;     }      /**      * fecha      *      * @return \datetime      */     public function getfecha()     {         return $this->fecha;     }      /**      * set fecha      *      * @param \datetime $fecha      * @return metrajediario      */     public function setfecha($fecha)     {         $this->fecha = $fecha;          return $this;     }      /**      * metrosperforados      *      * @return float      */     public function getmetrosperforados()     {         return $this->metrosperforados;     }      /**      * set metrosperforados      *      * @param float $metrosperforados      * @return metrajediario      */     public function setmetrosperforados($metrosperforados)     {         $this->metrosperforados = $metrosperforados;          return $this;     }      /**      * profundidadinicial      *      * @return float      */     public function getprofundidadinicial()     {         return $this->profundidadinicial;     }      /**      * set profundidadinicial      *      * @param float $profundidadinicial      * @return metrajediario      */     public function setprofundidadinicial($profundidadinicial)     {         $this->profundidadinicial = $profundidadinicial;          return $this;     }      /**      * descripcion      *      * @return string      */     public function getdescripcion()     {         return $this->descripcion;     }      /**      * set descripcion      *      * @param string $descripcion      * @return metrajediario      */     public function setdescripcion($descripcion)     {         $this->descripcion = $descripcion;          return $this;     }      /**      * sidetrack      *      * @return boolean      */     public function getsidetrack()     {         return $this->sidetrack;     }      /**      * set sidetrack      *      * @param boolean $sidetrack      * @return metrajediario      */     public function setsidetrack($sidetrack)     {         $this->sidetrack = $sidetrack;          return $this;     }      /**      * pozo      *      * @return \dipp\pozobundle\entity\pozo      */     public function getpozo()     {         return $this->pozo;     }      /**      * set pozo      *      * @param \dipp\pozobundle\entity\pozo $pozo      * @return metrajediario      */     public function setpozo(\dipp\pozobundle\entity\pozo $pozo = null)     {         $this->pozo = $pozo;          return $this;     }  } 

this controller code section involved creation form:

/**  * creates new metrajediario entity.  *  * @route("/", name="metrajediario_create")  * @method("post")  * @template("metrajebundle:metrajediario:new.html.twig")  */ public function createaction(request $request) {     $entity = new metrajediario();     $form = $this->createcreateform($entity);     $em = $this->getdoctrine()->getmanager();     $servicepozo = $this->get('service.pozo');     $sum = $em->getrepository('metrajebundle:metrajediario')->sumallmetrosperforados($servicepozo->getpozoactual());      if (!$sum) {         $sum = 0;     }     $entity->setprofundidadinicial($sum);     $form->handlerequest($request);      try {         /** validate beging */         $output = $this->validate($entity, $sum);         /** validate end */         if ($form->isvalid() && $output) {             $em = $this->getdoctrine()->getmanager();              $servicepozo = $this->get('service.pozo');             $entity                 ->setpozo($servicepozo->getpozoactual())                 ->setfecha($servicepozo->getfechaactual())                 ->setmetrosperforados(                     $entity->getmetrosperforados() - $sum                 );              $em->persist($entity);             $em->flush();             $this->get('service.message')->addsuccess($this->get('translator')->trans('status.create'));              return $this->redirect($this->generateurl('metrajediario_show', array('id' => $entity->getid())));         }     } catch (\exception $e) {         $this->get('service.message')->adderror($this->get('translator')->trans('metraje.error.create'));     }      return array(         'entity' => $entity,         'form' => $form->createview(),         'sum' => $sum,     ); }  /**  * creates form create metrajediario entity.  *  * @param metrajediario $entity entity  *  * @return \symfony\component\form\form form  */ private function createcreateform(metrajediario $entity) {     $form = $this->createform(new metrajediariotype(), $entity, array(         'action' => $this->generateurl('metrajediario_create'),         'method' => 'post',     ));      $form->add('submit', 'submit', array('label' => $this->get('translator')->trans('globals.add', array(), 'buttons'), 'attr' => array('class' => 'btn')));      return $form; }  /**  * displays form create new metrajediario entity.  *  * @route("/new", name="metrajediario_new")  * @method("get")  * @template()  */ public function newaction() {     $entity = new metrajediario();       $em = $this->getdoctrine()->getmanager();     $servicepozo = $this->get('service.pozo');     $sum = $em->getrepository('metrajebundle:metrajediario')->sumallmetrosperforados($servicepozo->getpozoactual());     $sugr = $em->getrepository('reportesdiariosbundle:parteoperacional')->findoneby(array('pozo' => $servicepozo->getpozoactual(), 'fecha' => $servicepozo->getfechaactual(), 'hora' => 4));      if (!$sum) {         $sum = 0;     }       $entity->setmetrosperforados($sugr == null ? 0 : $sugr->getprofundidadactual() );     $form = $this->createcreateform($entity);     return array(         'entity' => $entity,         'form' => $form->createview(),         'sum' => $sum     ); } 

and view:

{% extends 'plantillasbundle:plantillas:forms.html.twig' %}  {% form_theme form 'plantillasbundle:plantillas/labels:bootstrap_four_col.html.twig' %} {% form_theme form.sidetrack 'plantillasbundle:plantillas/nolabels:bootstrap_nolabels_four_col.html.twig' %} {% form_theme form.descripcion 'plantillasbundle:plantillas/labels:bootstrap_one_col.html.twig' %}  {% block formtitle -%}     <h3> {{ 'metraje.new' | trans({}, 'titles') }}</h3> {% endblock %}  {% block formbuttons %}     <div class="btn-group pull-right">         <a class="btn btn-info" href="{{ path('metrajediarios') }}">             <i class="fa fa-list-ul"></i> {{ 'actions.index' | trans({}, 'buttons') }}         </a>     </div> {% endblock %}  {% block formbody -%}     {{ form_start(form) }}     <div class="span3">         <label><b> {{ 'metraje.lastdepth' | trans({}, 'labels') }}</b></label>         <input id='ultimo-metraje' type="text" readonly value="{{ sum }}"/>     </div>     {{ form_rest(form) }}     {{ form_end(form) }} {% endblock %}  {% block scripts %}     {{ parent() }}     <script type='text/javascript' src='{{ asset('bundles/utiles/js/onclick.js') }}'></script>     <script>         $(document).ready(function () {             onclickhide("pozo_metrajebundle_metrajediario_descripcion", "pozo_metrajebundle_metrajediario_sidetrack");             $('#pozo_metrajebundle_metrajediario_sidetrack').on('click', function () {                 onclickhide("pozo_metrajebundle_metrajediario_descripcion", "pozo_metrajebundle_metrajediario_sidetrack");             });              var $btn = $('button[data-info=crear]');             $btn.on('click', function (e) {                 $('div.has-error').removeclass('has-error');                 var campo = $('#pozo_metrajebundle_metrajediario_metrosperforados');                 var nuevo = parsefloat($('#pozo_metrajebundle_metrajediario_metrosperforados').val());                 var ultimo = parsefloat($('#ultimo-metraje').val());                 var issidetrack = $('#pozo_metrajebundle_metrajediario_sidetrack:checked').length == 0;                 if (issidetrack && (nuevo < ultimo)) {                     $($(campo).parents('div').get(0)).addclass('has-error');                     mostrarmodalalert('{{ 'message.error' | trans({}, 'titles') }}', '{{ 'metraje.error.modalalert2' | trans({}) }}');                     return false;                 }                 else if (!issidetrack && !(nuevo < ultimo)) {                     $($(campo).parents('div').get(0)).addclass('has-error');                     mostrarmodalalert('{{ 'message.error' | trans({}, 'titles') }}', '{{ 'metraje.error.modalalert1' | trans({}) }}');                     return false;                 }                 $guardar.trigger('guardar');                 return false;             });         });     </script> {% endblock %} 

and there tree form_theme apply form's widgets.

{% block form_row -%}     <div class="clearfix"></div>     <div class="row-fluid {% if (not compound or force_error|default(false)) , not valid %} has-error{% endif %}">         {{- form_label(form) -}}         {{- form_widget(form) -}}      </div> {%- endblock form_row %}   {% block form_row -%}     <div class="span3 {% if (not compound or force_error|default(false)) , not valid %} has-error{% endif %}">         {#{{- form_label(form) -}}#}         {{- form_widget(form) -}}      </div> {%- endblock form_row %}    {% block form_row -%}     <div class="span3 {% if (not compound or force_error|default(false)) , not valid %} has-error{% endif %}">         {#{{- form_label(form) -}}#}         {{- form_widget(form) -}}      </div> {%- endblock form_row %} 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -