Jump to content

Problema de validación 'The use of smarty templates is mandatory to display HTML'


Recommended Posts

Hola a todos.

Soy programador web, y hace ya un par de años que ofrecemos prestashop a nuestros clientes. Según las necesidades que han ido surgiendo, hemos creado módulos propios, y como algunos son muy demandados hemos decidido publicarlos en Prestashop Addons.

El modulo pasa la validación en validator.prestashop.com, bueno salvo los standars que por lo que he leido no son necesarios.

El problema es que, un modulo que funciona perfectamente (de hecho lleva ya 1 años siendo usado por varios clientes), no me pasa la validación técnica al subirlo a prestahsop addons, el error es siempre el mismo:

 

'The use of smarty templates is mandatory to display HTML. Your PHP code should not contain HTML.'

 

Vale, lo que dice el mensaje está claro, pero es que he rehecho el código, sin usar html dentro del codigo y me sigue saliendo, y como no dice exactamente en que archivo ni lugar está el problema estoy un poco perdido.

 

El getcontent es este:

    public function getContent()
    {
        /**
         * If values have been submitted in the form, process.
         */
        if (((bool)Tools::isSubmit('submitPagoscecatpvnmModule')) == true) {
            $this->postProcess();
        }
        $this->context->smarty->assign('module_dir', $this->_path);
		$this->context->smarty->assign('titulo',$this->displayName.' - '.$this->version);
		$this->context->smarty->assign('urlweb',$_SERVER['HTTP_HOST'].__PS_BASE_URI__);
		$this->context->smarty->assign('info',$this->l('Module for configure and allow CECA tpv payments'));
		
		$this->context->smarty->assign('warning', ($this->getMode() ? '' : $this->l('TEST MODE ENABLED')) );

        $output = $this->context->smarty->fetch($this->local_path.'views/templates/admin/configuration.tpl');
        return $output.$this->renderForm();
    }
	private function _displayInfos()
	{
		
        $this->context->smarty->assign('module_dir', $this->_path);
		$this->context->smarty->assign('version',$this->displayName.' - '.$this->version);
		$this->context->smarty->assign('urlweb',$_SERVER['HTTP_HOST'].__PS_BASE_URI__);
		$this->context->smarty->assign('uri',$_SERVER['REQUEST_URI']);
		$this->context->smarty->assign('info',$this->l('Module for configure and allow CECA tpv payments'));
		$this->context->smarty->assign('stamp',date("dmYHis"));
		$this->context->smarty->assign('warning', ($this->getMode() ? '' : $this->l('TEST MODE ENABLED')) );

		return $this->display(__FILE__, '/views/templates/admin/infos.tpl');
	}
    protected function renderForm()
    {
        $helper = new HelperForm();

        $helper->show_toolbar = true;
        $helper->table = $this->table;
        $helper->module = $this;
        $helper->default_form_language = $this->context->language->id;
        $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0);

		$helper->toolbar_scroll = true;
        $helper->identifier = $this->identifier;
        $helper->submit_action = 'submitPagoscecatpvnmModule';
        $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false)
            .'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
        $helper->token = Tools::getAdminTokenLite('AdminModules');
		
        $helper->tpl_vars = array(
            'fields_value' => $this->getConfigFormValues(), /* Add values for your inputs */
            'languages' => $this->context->controller->getLanguages(),
            'id_language' => $this->context->language->id,
        );
		
        return $helper->generateForm(array($this->getConfigForm())).$this->_displayInfos();  
    }

En el getcontent utlizo el generateform para generar el formulario y le añado un .tpl con displayInfos que muestra información adicional.

Lo que pretendo con esto es mostar un caja debajo del formulario de configuración... igual lo estoy haciendo mal y hay que hacerlo de otra manera...

 

Por otro lado, tengo también dentro del array del form defino unos controles tipo radio que quiero que me muestre una imagen al lado, y lo hice así:

...
$optionsselect=array(
  'type'      => 'radio',                            
  'label'     => $this->l('Image button'),       
  'name'      => 'IMAGE_OPT',                             
  'is_bool'   => false,         
											
  'values'    => array(                   
	array('id'=> 'option_simple','value' => 'simple','label' => '<img src="'.$this->_path.'/views/img/simple.png" />'),
	array('id'=> 'option_black','value' => 'black','label' => '<img src="'.$this->_path.'/views/img/black.png" />')
	),
);
...

y sí, incluyo en el label html para que muestre la imagen, no se como hacerlo de otra manera, he mirado la doc de prestashop y no veo nada al respecto.

 

Saludos y gracias de antemano.

Link to comment
Share on other sites

Hola, gracias por responder.

Hombre, si son importantes porque muestran una imagen que se selecciona y aparece como botón de pago (es un módulo de pago). ¿Y usando el type='html' y creando yo a mano el select... he visto modulo nativos de prestashop que utilizan eso, por ejemplo he visto que el controller nativo de prestashop para modificar el perfil del usuario, AdminEmplyees usa esto:
 

...	
public function renderForm()
	{
		if (!($obj = $this->loadObject(true)))
			return;

		$available_profiles = Profile::getProfiles($this->context->language->id);

		if ($obj->id_profile == _PS_ADMIN_PROFILE_ && $this->context->employee->id_profile != _PS_ADMIN_PROFILE_)
		{
			$this->errors[] = Tools::displayError('You cannot edit the SuperAdmin profile.');
			return parent::renderForm();
		}

		$this->fields_form = array(
			'legend' => array(
				'title' => $this->l('Employees'),
				'icon' => 'icon-user'
			),
			'input' => array(
				array(
					'type' => 'text',
					'class' => 'fixed-width-xl',
					'label' => $this->l('First Name'),
					'name' => 'firstname',
					'required' => true
				),
				array(
					'type' => 'text',
					'class' => 'fixed-width-xl',
					'label' => $this->l('Last Name'),
					'name' => 'lastname',
					'required' => true
				),
				array(
					'type' => 'html',
					'name' => 'employee_avatar',
					'html_content' => '<div id="employee-thumbnail"><a href="http://www.prestashop.com/forums/index.php?app=core&module=usercp" target="_blank" style="background-image:url('.$obj->getImage().')"></a></div>
					<div class="alert alert-info">'.sprintf($this->l('Your avatar in PrestaShop 1.6.x is your profile picture on %1$s. To change your avatar, log in to PrestaShop.com with your email %2$s and follow the on-screen instructions.'), '<a href="http://www.prestashop.com/forums/index.php?app=core&module=usercp" class="alert-link" target="_blank">PrestaShop.com</a>', $obj->email).'</div>',
				),
...

Fijate en el 'type' => 'html', en el que inyecta html directamente ....

Link to comment
Share on other sites

Bueno, pues al final pues creo que es de recibo os comente como acabo esta historia, que igual le sirve a otro que la pase algo parecido.

Quite el html de los label pero seguía sin validar, el mismo error. Les envie contesté en el propio correo que me llego con la denegación indicando que me dieran más datos de donde esta el error y me contestan que el problema es que en una funcion, la que devuelve el array con el formulario tengo html, pero en los comentarios ¿!

...
    protected function getConfigForm()
    {
        return array(

            'form' => array(
                'legend' => array(
                'title' => $this->l('TPV Configuration'),
                'icon' => 'icon-cogs',
                ),
				'description' => $infolog,
                'input' => array(
						array(
					  //'type' => 'html',
					  'type'      => 'radio',                               // This is an <input type="checkbox"> tag.
					  'label'     => $this->l('Image for PAY button'),        // The <label> for this <input> tag.
					  'desc'      => ' ',   // A help text, displayed right next to the <input> tag.
					  'name'      => 'CECATPVNM_IMAGE',                              // The content of the 'id' attribute of the <input> tag.
					  'required'  => true,                                  // If set to true, this option must be set.
					  'class'     => 't',                                   // The content of the 'class' attribute of the <label> tag for the <input> tag.
					  'is_bool'   => false,                                  // If set to true, this means you want to display a yes/no or true/false option.
																			// The CSS styling will therefore use green mark for the option value '1', and a red mark for value '2'.
																			// If set to false, this means there can be more than two radio buttons,
																			// and the option label text will be displayed instead of marks.
					  'values'    => array(                                 // $values contains the data itself.
						array(
						  'id'    => 'option_3d',                           // The content of the 'id' attribute of the <input> tag, and of the 'for' attribute for the <label> tag.
						  'value' => '3d',                                     // The content of the 'value' attribute of the <input> tag.   
						'label' => '3d'
						),
...

Es decir, yo copie el código para hacer el array directamente de la doc de prestashop, y en el código hay comentario ¡con html! que es lo que no valida... bufff... en fin.

Ahora he enviado el código limpio, ya hace 2 días (desde el lunes), y el modulo esta en espera de validación técnica y de marketing desde entonces... antes en menos de una hora ya me llegaba la notificación de denegación, supongo que por algun proceso automático, por lo que entiendo que la cosa va para adelante... ¿suelen tardar tanto en hacerse una validación técnica?

 

Bueno ,espero sirva a otros y gracias por ayudar.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...