This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Custom buildviolation atPath to form collection

New topics about Symfony 2 should go here

Custom buildviolation atPath to form collection

by karop » Fri May 15, 2015 8:50 pm

Hi,

I'm trying to refer to form collection in my custom Callback constraint:
Code: Select all
if (strlen($messageLine->getText()) > 10) {
    $context->buildViolation('Text in line too long')
    ->atPath('messageLines')
    ->addViolation();
    break;
}


And this is the form:
Code: Select all
{{ form_label(form.messageLines) }}
          
<ul class="message_lines" data-prototype="
                  {% filter escape %}
                      {{ include('ChocopostBundle:Order:prototype.html.twig', { 'form': form.messageLines.vars.prototype }) }}
                  {% endfilter %}">
    {% for messageLine in form.messageLines %}
        <li>{{ form_widget(messageLine.text) }}{{ form_errors(messageLine.text) }}</li>
    {% endfor %}
</ul>
{{ form_errors(form.messageLines) }}


How can I point atPath() to "messageLine.text"?
karop
Junior Member
 
Posts: 13
Joined: Tue Oct 02, 2012 4:25 pm