<commit_before><?php
/**
 * TicketsField.php
 *
 * @author <NAME>
 * Date: 10/03/17
 */

namespace Broarm\EventTickets;

use ArrayList;
use DataList;
use DBField;
use DropdownField;
use FormField;
use NumericField;
use Validator;

/**
 * Class TicketsField
 *
 * @package Broarm\EventTickets
 */
class TicketsField extends FormField
{

    protected $tickets;

    protected $template = 'TicketsField';

    public function __construct($name, $title, DataList $tickets)
    {
        $this->tickets = $tickets;
        parent::__construct($name, $title);
    }

    /**
     * Set the ticket list
     *
     * @param DataList $tickets
     */
    public function setTickets(DataList $tickets)
    {
        $this->tickets = $tickets;
    }

    /**
     * Get the ticket list
     *
     * @return DataList
     */
    public function getTickets()
    {
        return $this->tickets;
    }

    /**
     * Get a list of editable tickets
     * These have an numeric input field
     *
     * @return ArrayList
     */
    private function getEditableTickets()
    {
        $tickets = ArrayList::create();
        foreach ($this->getTickets() as $i => $ticket) {
            /** @var Ticket $ticket */
            $fieldName = $this->name . "[{$ticket->ID}][Amount]";
            $range = range($ticket->Event()->OrderMin, $ticket->Event()->OrderMax);

            $ticket->AmountField = DropdownField::create($fieldName, 'Amount', array_combine($range, $range))
                ->setHasEmptyDefault(true)
                ->setEmptyString(_t('TicketsField.EMPTY', 'Tickets'));

            // Set the first to hold the minimum
            if ($i === 0) {
                $ticket->AmountField->setValue($ticket->Event()->OrderMin);<commit_msg>when multiple dont set default ticket<commit_after><?php
/**
 * TicketsField.php
 *
 * @author <NAME>
 * Date: 10/03/17
 */

namespace Broarm\EventTickets;

use ArrayList;
use DataList;
use DBField;
use DropdownField;
use FormField;
use NumericField;
use Validator;

/**
 * Class TicketsField
 *
 * @package Broarm\EventTickets
 */
class TicketsField extends FormField
{

    protected $tickets;

    protected $template = 'TicketsField';

    public function __construct($name, $title, DataList $tickets)
    {
        $this->tickets = $tickets;
        parent::__construct($name, $title);
    }

    /**
     * Set the ticket list
     *
     * @param DataList $tickets
     */
    public function setTickets(DataList $tickets)
    {
        $this->tickets = $tickets;
    }

    /**
     * Get the ticket list
     *
     * @return DataList
     */
    public function getTickets()
    {
        return $this->tickets;
    }

    /**
     * Get a list of editable tickets
     * These have an numeric input field
     *
     * @return ArrayList
     */
    private function getEditableTickets()
    {
        $tickets = ArrayList::create();
        foreach ($this->getTickets() as $ticket) {
            /** @var Ticket $ticket */
            $fieldName = $this->name . "[{$ticket->ID}][Amount]";
            $range = range($ticket->Event()->OrderMin, $ticket->Event()->OrderMax);

            $ticket->AmountField = DropdownField::create($fieldName, 'Amount', array_combine($range, $range))
                ->setHasEmptyDefault(true)
                ->setEmptyString(_t('TicketsField.EMPTY', 'Tickets'));

            // Set the first to hold the minimum
            if ($this->getTickets()->count() === 1) {
                $ticket->AmountField->setValue($ticket->Event()->OrderMin);
{'fraction_non_alphanumeric': 0.14014722536806343, 'fraction_numerical': 0.003963759909399773, 'mean_word_length': 2.3456439393939394, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '94581', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1031, 'n_words': 245}