We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Volt link_to onclick a

Hi @all,

how can i generate this in volt:

            {% for media in user.media %}
                {{ link_to( "onclick" : "return launchEditor(image_1_" ~ media.usersId, media.image_1")", 'class' : 'btn btn-flat btn-default', '<i class="fa fa-picture-o"></i> Bild bearbeiten') }}
            {% endfor %}

I get this message:

Syntax error, unexpected token STRING() in C:\xampp\htdocs\projects\vokuro/app/views/profiles/index.volt on line 30
#0 [internal function]: Phalcon\Mvc\View\Engine\Volt\Compiler->_compileSource('\n{{ content() }...', false)
#1 [internal function]: Phalcon\Mvc\View\Engine\Volt\Compiler->compileFile('C:\\xampp\\htdocs...', 'C:\\xampp\\htdocs...', false)
#2 [internal function]: Phalcon\Mvc\View\Engine\Volt\Compiler->compile('C:\\xampp\\htdocs...')
#3 [internal function]: Phalcon\Mvc\View\Engine\Volt->render('C:\\xampp\\htdocs...', Array, true)
#4 [internal function]: Phalcon\Mvc\View->_engineRender(Array, 'profiles/index', true, true, NULL)
#5 [internal function]: Phalcon\Mvc\View->render('profiles', 'index', Array)
#6 C:\xampp\htdocs\projects\vokuro\public\index.php(33): Phalcon\Mvc\Application->handle()
#7 {main}


34.6k
Accepted
answer
edited Sep '15
{{ link_to( "onclick" : "return launchEditor(image_1_" ~ media.usersId ~ ", " ~ media.image_1 ~ ")", 'class' : 'btn btn-flat btn-default', '<i class="fa fa-picture-o"></i> Bild bearbeiten') }}


60.0k

Hi Andres,

thank you for you help. Your example almost work, i did some changes:

{{ tag_html("a", ["href":"#",'onclick' : 'return launchEditor("image_1_' ~ media.usersId ~    '","' ~media.image_1 ~ '");', 'class' : 'btn btn-flat      btn-default']) }}
    <i class="fa fa-picture-o"></i> Bild bearbeiten
{{ tag_html_close("a") }}

Now it works perfect for me :-)

Kind regards

Stefan