verbb / events

Craft CMS Plugin for events management and ticketing.
Other
22 stars 13 forks source link

No error validation for ticket type #115

Closed anchovy closed 1 year ago

anchovy commented 2 years ago

Describe the bug

If you add a ticket by don't select a ticket type an Twig\Error\RuntimeError is thrown rather than a form error in line i.e. no price added.

Steps to reproduce

  1. Add/Edit an event

  2. Goto the tickets tab

  3. Click 'Add Ticket'

  4. Enter a price but don't select a ticket type

  5. Save the form

  6. A Error is thrown:

    
    Twig Runtime Error – [Twig\Error\RuntimeError]
    Impossible to invoke a method ("getFieldLayout") on a null variable.
  7. in /....../vendor/verbb/events/src/templates/_includes/ticket-row.htmlat line 97 instructions: 'Tickets will not be purchasable after this date.' | t('events'), id: 'availableTo', name: 'availableTo', value: ticket.availableTo ?? [], errors: ticket ? ticket.getErrors('availableTo'), }) }}

        <div class="ticket-type-fields">
            {% if ticket %}
                {% for tab in ticket.type.getFieldLayout().getTabs() %}
                    {% include '_includes/fields' with {
                        fields: tab.getFields(),
                        element: ticket,
                    } only %}
                {% endfor %}
            {% endif %}
        </div>
    </div>

Craft CMS version

Craft Pro 3.7.55.3

Plugin version

1.4.23

Multi-site?

No

Additional context

As per not adding a price, I'd expect an inline error ie: image

engram-design commented 2 years ago

Fixed for the next release. To get the fix early, change your verbb/events requirement in composer.json to:

"require": {
  "verbb/events": "dev-craft-3 as 1.4.23",
  "...": "..."
}

Then run composer update.

engram-design commented 1 year ago

Fixed in 1.4.24